According to the accepted answer to this question GridView row height, if you...
"Set your LinearLayouts to be some specific height, and the rows will all be that height."
This does not appear to work in my case. I have a layout file for each row as so:
<?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 these are contained within a Gridview defined as so:
<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 the 'android:layout_height="200dp"' and instead sets the row height to the cell's content.
What's worse is that when my TextView wraps onto a second line, that second line is obscured by the next row of cells.
What am I missing?
The problem is solved in the following question: Layout problem with button margin
android:layout_*
attributes are LayoutParams
and belong to the parent view. So they will be ignored if you don't specify any parent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With