Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: gridview

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>
like image 808
ekjyot Avatar asked Jan 22 '26 07:01

ekjyot


2 Answers

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.

like image 157
Paresh Mayani Avatar answered Jan 24 '26 20:01

Paresh Mayani


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.

like image 34
alex.zherdev Avatar answered Jan 24 '26 20:01

alex.zherdev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!