How can I get vertical scroll in android gridview?

I am developing an Android application with image display. I use grid view to display images in my application.

But the default gridview is horizontal scrolling I want to show the images as a vertical scrolling grid.

Please suggest me a way to achieve vertical scroll in gridview.

Thanks in advance.

+4
source share
1 answer

Use android:numColumns="3" // this will force gridview to have 3 columns and if you have more than 3 items in grid view, you can have vertical scrolling.

Example:.

 <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridView1" android:numColumns="3" android:gravity="center" android:columnWidth="50dp" android:stretchMode="columnWidth" android:layout_width="fill_parent" android:layout_height="fill_parent" > </GridView> 
+3
source

Source: https://habr.com/ru/post/1434571/


All Articles