GridView row height

后端 未结 3 2027
暖寄归人
暖寄归人 2020-12-04 22:16

I have a GridView that displays images, which are, unfortunately, of different sizes. They are shown in between two lines of text:

text1.1                tex         


        
相关标签:
3条回答
  • 2020-12-04 22:52

    Here is an alternative solution that pre-measures items and sets the height of each cell to the max height in that row.

    GridView rows overlapping: how to make row height fit the tallest item?

    0 讨论(0)
  • 2020-12-04 23:01

    You are in control over your row heights, by virtue of what you put in them. Since your cells appear to have more than one widget, they are presumably wrapped in a LinearLayout or something. Set your LinearLayouts to be some specific height, and the rows will all be that height.

    Personally, I think you should be resizing your images if you are going to have text above and below each image on a per-cell basis.

    0 讨论(0)
  • 2020-12-04 23:11

    Use drawable as background on Layout that is your grid cell and define that drawable with:

    <size android:height="<some height>" />
    

    For example:

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
    <solid android:color="#ffffff"/>
    <size android:height="60dip" />
    </shape>
    
    0 讨论(0)
提交回复
热议问题