Is there anyway to set the no of row in GridView Android

半世苍凉 提交于 2019-12-06 14:36:54

If you need to display a fixed number of images (for example using ImageView) horizontally, the best solution is using HorizontalScrollView with a single horizontal LinearLayout child, which will contain the images. It will look something like this:

<HorizontalScrollView android:layout_width="match_parent"
                      android:layout_height="wrap_content">
    <LinearLayout android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal">
        <ImageView ...
                   ... />
        <ImageView ...
                   ... />
        ...
    </LinearLayout>
</HorizontalScrollView>
gaurav5430

GridView is not really designed for this purpose, it is designed to display an indefinite amount of data in an efficient scrolling manner. If you want to create a static layout where you can discretely place items at specific locations, you should be looking at GridLayout or TableLayout instead.

from

How to set a fixed number of rows in android gridView?

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