android - 如何使 GridView 在 android 中水平滚动而不是垂直滚动?

标签 android grid horizontal-scrolling

我有一个动态 GridView 。表示其内容各不相同。所以,如果项目数量增加,它就会垂直滚动。我想把它做成水平滚动。

请为此提出一些解决方案。

最佳答案

        <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/seatLegendLayout">

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:id="@+id/linearLayout_gridtableLayout"
                android:layout_width="900dp"
                android:layout_height="match_parent"
                android:orientation="horizontal">

                <GridView
                    android:id="@+id/gridView1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_margin="4dp"
                    android:columnWidth="100dp"
                    android:gravity="center"
                    android:numColumns="9"
                    android:horizontalSpacing="1dp"
                    android:scrollbarAlwaysDrawHorizontalTrack="true"
                    android:scrollbarAlwaysDrawVerticalTrack="true"
                    android:scrollbars="horizontal"
                    android:stretchMode="none"
                    android:verticalSpacing="1dp">

                </GridView>


            </LinearLayout>
        </FrameLayout>
    </HorizontalScrollView>

关于android - 如何使 GridView 在 android 中水平滚动而不是垂直滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15919060/

相关文章:

html - 如何在页面上水平滚动

html - Bootstrap 3 网格大小调整问题

html - 网格布局中的 "holes",Zurb 基金会

android - ListFragment 中的 IllegalStateException

java - 如何在java中更改按钮背景?

html - 元素之间具有填充/边距的网格布局

html - 如何将水平滚动条添加到 HTML 表格中的特定列数?

html - 如何摆脱页面的水平滚动

Android TableLayout 高度不填满整个屏幕

java - getPurchasesList 空指针异常