I am using a GridView. Four items in a column. Each element is composed of the following layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="32dip"
android:layout_height="32dip"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="11dip"
android:paddingTop="2dip" />
</LinearLayout>
So each element is a small image with a bit of text below it. The layout works great on the first pass. However, if an item's text is long, it wraps to two lines. This works ok, until you scroll it in and out of view. By default, all the images in a row are top-aligned. When you scroll a row off-screen, then back on screen, you'll see that the row somehow gets bottom-aligned. It looks like:
First layout:
[image] [image] [image]
[text] [text] [text
wrap]
so even though the third element has 2 lines of text, the tops are aligned which is perfect. If I scroll this row off screen, then back on, it looks like this:
[image]
[image] [image] [text
[text] [text] wrap]
so the row gets bottom-aligned here. I'm not sure if this is a bug in GridView, or if there's some way to control the layout to always top-align rows. I've tried setting the gravity of the element layout to "top", no good. There also doesn't appear to be any setting unique to GridView to control this. Any ideas?
Thanks
The height of the items in the GridView must be the same. You have 2 or 3 options.
android:singleLine="true"
android:minLines="2"
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