tags:

views:

75

answers:

1

Hello All,

I want to display GridView (with text and image) and group of text box below grid view.

Problem is my gridview do not have fixed entries. It is varying between 1 & 10. I want to resize it as per count of items in grid view. How can i do that? Where can i get height of gridview in JAVA code?

Also, i want to display my group of text boxes ALWAYS at bottom of activity. How can i do that?





   
 
 
 

Thanks, JC

A: 

I want to resize it as per count of items in grid view.

I really don't recommend that.

Also, i want to display my group of text boxes ALWAYS at bottom of activity. How can i do that?

Step #1: Put the GridView and the LinearLayout inside a RelativeLayout

Step #2: Anchor the LinearLayout to the bottom via android:layout_alignParentBottom="true"

Step #3: Anchor the GridView to the top (android:layout_alignParentTop="true") and to the top of the LinearLayout (android:layout_above="...")

This will cause your GridView to expand to fill the space in the RelativeLayout except that which is taken up by the LinearLayout at the bottom. You can size and position the RelativeLayout yourself as you see fit (e.g., set width and height to fill_parent to have it fill the screen).

CommonsWare
Thanks a ton. It worked like a champ !! this will allow gridview to span till remaining space. What will happen if entries in grid view are more, will it scroll or overlay? It is scrolling so it will work for me...again thanks !!
JRC
@JRC: "What will happen if entries in grid view are more, will it scroll or overlay?" -- scroll. It will not overlap the `LinearLayout`.
CommonsWare