2017-01-03 36 views
0

不匹配的图像的高度,我有以下的GridView:GridView的项目,即使它设置为wrap_content

<GridView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/gridView" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentStart="true" 
    android:numColumns="3" /> 

我与该类型项目的填写:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/imageView"/> 
</LinearLayout> 

我通过设置位图在适配器中设置图像。图像为3列的GridView获得适当的大小,但是项目太高。这意味着每张图片上方和下方都有很多空白区域。我怎样才能移除这个空间以便物品与图像具有相同的高度?

下面是它是现在怎么样一个例证: enter image description here

这里就应该是这样: enter image description here

回答

1

在XML中添加这种,

<ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:adjustViewBounds="true" 
     android:id="@+id/imageView"/> 
+0

谢谢你,它的工作:) – user3600338

相关问题