Android Grid view with 3 rows and 3 columns

℡╲_俬逩灬. 提交于 2019-12-10 14:17:29

问题


I unable to set no. of rows for grid view. Only able to set no. of columns.

I need to create a grid view which has 3 rows and 3 columns.

Can any one help me please.

This is my XML layout code:

<GridView android:id="@+id/gridView" 
   android:layout_width="match_parent" 
   android:layout_height="match_parent" 
   android:numColumns="3" 
   android:gravity="center" 
   android:stretchMode="columnWidth" > 
</GridView>

Thanks in advance, Deepak


回答1:


Add this attribute to your android XML

android:numColumns="3"

This will allow you to have only 3 columns and give the

android:layout_width="match_parent"

Then add 3 rows may be it will help.

Try it.



来源:https://stackoverflow.com/questions/24796133/android-grid-view-with-3-rows-and-3-columns

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