How can i get Vertical scrolling in GridView android?

半世苍凉 提交于 2019-12-18 08:47:11

问题


I am developing an android application with showing images. I am using grid view to show the images in my application.

But default gridview is horizontal scrolling I want to show the images in vertical scrolling grid view.

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

Thanks in advance.


回答1:


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.

Ex.:

<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>


来源:https://stackoverflow.com/questions/12456711/how-can-i-get-vertical-scrolling-in-gridview-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!