3

I have make a gridview in which i have added images . But my problem is that it is showing very small size of gridview with only 3 images in it like in the picture and i want to show 9 images in it.

enter image description heres

But i want that the gridview size to be fill parent that is below photos and above bottom scroll bar.

I am using the following xml for it

 <RelativeLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_above="@+id/LinearLayouToolbar" android:layout_below="@+id/linearLayout3"> <ScrollView android:layout_height="200dp" android:layout_width="320dp" android:id="@+id/scrollView1" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"> <GridView android:horizontalSpacing="10dp" android:columnWidth="80dp" android:verticalSpacing="20dp" android:stretchMode="columnWidth" android:padding="10dp" android:id="@+id/GridView01" android:fastScrollEnabled="true" android:layout_gravity="fill|center" android:numColumns="auto_fit" android:layout_marginBottom="0dp" android:layout_width="wrap_content" android:layout_height="wrap_content"></GridView> </ScrollView> </RelativeLayout> 
3
  • 1
    Can you post the whole layout? Commented Oct 31, 2011 at 10:11
  • 2
    don't use gridview inside scrollview. android:layout_width="wrap_content" android:layout_height="wrap_content" and set above attribute to fillparent. Commented Oct 31, 2011 at 10:12
  • Since you set height of scrollview to 200dp hence it places gridview in within allocated height. Commented Oct 31, 2011 at 10:14

2 Answers 2

4

Correct your scroll view width and height as:

 <ScrollView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/scrollView1" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"> 

Otherwise remove the ScrollView, just give GridView inside the RelativeLayout.

Sign up to request clarification or add additional context in comments.

1 Comment

it is quite forbidden to put a gridview in a scrollview, anyway
4

You should not put a gridview (as well as a listview) inside a scrollview. In your case it seems superfluous, because the gridview will provide the scrolling for itself.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.