android - 无论如何要在 GridView Android 中设置行数

标签 android gridview android-gridview

可能是我问错了问题。但是请大家帮帮我。我想以 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/

相关文章:

android - 如何在Imageview中获取图像的高度?

Android actionBar OnClick()

android - 如何在 Android 的 GridView 中使用预加载器

c# - 在 gridview 中获取特定的数据行?

java - 带有部分标题的 Android GridView

android - 在 1 行和多列中显示带有水平滚动条的 GridView 或画廊的图像和文本

c# - Xamarin:创建自定义 GridView

java - 如何让Java从Internet调用数据?从哪里开始呢?

android - 如何通过改造正确处理文本/纯文本响应?

c# - 使用图像将 Gridview 导出到 Excel