According to the accepted answer to this question GridView row height if you ...
"Set LinearLayouts as a specific height, and all lines will be that height."
In my case, this does not work. I have a layout file for each line like this:
<?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="200dp" android:layout_gravity="center_horizontal"> <ImageView android:id="@+id/theimage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:background="#ffff0000" /> <TextView android:id="@+id/thename" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:gravity="center" style="?icontext" android:background="#ff00ff00"/> </LinearLayout>
And they are contained inside a Gridview defined like this:
<GridView android:id="@+id/gridview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:numColumns="auto_fit" android:columnWidth="100dp" android:background="@color/background" android:verticalSpacing="1dp" android:horizontalSpacing="5dp" />
This ignores "android: layout_height =" 200dp "" and instead sets the row height for the contents of the cell.
What's worse, when my TextView is wrapped in a second row, this second row is closed by the next row of cells.
What am I missing?
source share