如何更改 GridView 滚动类型?
Posted
技术标签:
【中文标题】如何更改 GridView 滚动类型?【英文标题】:How can i change GridView scrolling type? 【发布时间】:2018-07-06 19:24:14 【问题描述】:我想更改 GridView 滚动样式以滚动一个部分(如使用 ViewPager)而不是一次滚动一行。 谁能告诉我在不使用任何第三方库的情况下实现此行为的最佳方法是什么?
【问题讨论】:
recyclerView 能满足您的需求吗? 【参考方案1】:这里有一个post,它解释了如何将 GridView 与水平滚动一起使用,据我所知,如果你想让它作为 ViewPager 工作,你正在努力实现这一目标
基本上你插入 GridView 在 HorizontalScrollView
内 <HorizontalScrollView
android:layout_
android:layout_
android:layout_below="@+id/seatLegendLayout">
<FrameLayout
android:layout_
android:layout_>
<LinearLayout
android:id="@+id/linearLayout_gridtableLayout"
android:layout_
android:layout_
android:orientation="horizontal">
<GridView
android:id="@+id/gridView1"
android:layout_
android:layout_
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>
【讨论】:
这会滚动很多列而不是每次滚动一列吗? 您要水平滚动还是垂直滚动?这个不清楚 我想要一个网格视图分页。我添加了一个展示我想要的视频:m.youtube.com/watch?v=jsAWx5zWo-Q(移到最后)我没有这样做,因为我想要更简单的东西而不是使用两个适配器以上是关于如何更改 GridView 滚动类型?的主要内容,如果未能解决你的问题,请参考以下文章