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>
ekjyot
  • 2,247
  • 7
  • 39
  • 63

2 Answers2

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.

alex.zherdev
  • 23,914
  • 8
  • 62
  • 56
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.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295