可能是我问错了问题。但是请大家帮帮我。我想以 GridView 格式显示图像。 我现在有 5 张图片,我想像这样显示这些图片(可以单行滚动)。
image1 image2 image3 image4 image5
但在移动端我们可以一次显示 2 或 3 个。我们可以像 numColumn:2
那样设置 Grid View 的行数吗?
感谢考虑。
最佳答案
如果您需要水平显示固定数量的图像(例如使用 ImageView
),最好的解决方案是使用 HorizontalScrollView
单水平 LinearLayout
child,它将包含图像。它看起来像这样:
<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>
关于android - 无论如何要在 GridView Android 中设置行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20748126/