If you want to see all of the rows you need to set layout_height=fill_parent not layout_width=fill_parent and layout_height=wrap_content. It won't be able to show all the rows though unless you make them all really small anyway depending on the number of cells you have. If you have a lot of cells then it is pointless to even try to get them to show up on one screen.


Nicholas L. - NWD Sports.com Co-Founder
-----Original Message----- From: Shri
Sent: Friday, September 02, 2011 7:33 PM
To: Android Developers
Subject: [android-developers] GridView shows only one row with layout_height=WRAP_CONTENT

I am using a GridView in a LinearLayout. I want the GridView to show
up as tall as needed to show all the rows. However, I am seeing only
one row when set (layout_width=MATCH_PARENT and)
layout_height=WRAP_CONTENT. If I set layout_height to a size that
equals mulitple rows, then I do see those rows.

Looking at onMeasure in http://www.netmite.com/android/mydroid/frameworks/base/core/java/android/widget/GridView.java,
I see that onMeasure does not calculate the number of rows at all, and
so I can understand why only one row shows up. So it seems like an
oversight.

Shouldn't layout_height=WRAP_CONTENT show all rows (if possible)? Is
there any workaround?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to