gridView height is too tall when using an imageView inside

安稳与你 提交于 2019-12-04 05:40:47

I think you haven't set adjustViewBounds to true. Can you set as follows?

imageView.setAdjustViewBounds(true);

Here i have user 3 column for in each row and it works fine. Gallery view set the column width at run time,

mPhotoGalleryGridView.setColumnWidth(display.getWidth() / 3);

in layout

<GridView android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/photogallerygridview"      
    android:padding="5dp"
    android:verticalSpacing="5dp"
    android:horizontalSpacing="5dp"
    android:stretchMode="columnWidth"
    android:numColumns="3"
    android:gravity="center">    
</GridView>

in adapter: set imageview height and width,

imageview.setMaxHeight(150);
        imageview.setMinimumHeight(150);

Hope useful to you.

Try the below code. The width should be in dips

 android:adjustViewBounds="true"
 android:maxWidth="150dip"
 android:maxHeight="150dip"
ankita gahoi

Use wrap_content instead of using fill_parent.

Because fill_parent will actually take original height of image and try to fill it in the screen. Even if u use 400x400 image and set layout_width = "160dp" and layout_height = "160dp" , it will work because we are not allowing image to display more than that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!