[英]Is there anyway to set the no of row in GridView Android
May be i am asking wrong question. 可能是我问错了问题。 But please guys help me out.
但是请大家帮我。 i want to display images in Grid View format.
我想以“网格视图”格式显示图像。 I have 5 images now i want to display these images like this(in single row scroll able).
我现在有5张图像,我想像这样显示这些图像(能够单行滚动)。
image1 image2 image3 image4 image5
But in mobile we can display 2 or 3 at a time. 但是在移动设备中,我们一次可以显示2或3。 Can we set the number of rows in Grid View like
numColumn:2
? 我们可以像
numColumn:2
这样在Grid View中设置行数吗? Thanks for considering. 感谢您的考虑。
GridView
is not really designed for this purpose, it is designed to display an indefinite amount of data in an efficient scrolling manner. GridView
并不是真正为此目的而设计的,它旨在以有效的滚动方式显示无限量的数据。 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. 如果要创建静态布局,可以在其中将项目离散地放置在特定位置,则应该查看
GridLayout
或TableLayout
。
from 从
How to set a fixed number of rows in android gridView? 如何在android gridView中设置固定的行数?
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. 如果需要水平显示固定数量的图像(例如,使用
ImageView
),最好的解决方案是将HorizontalScrollView
与单个水平LinearLayout
子级一起使用,该子级将包含图像。 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.