【发布时间】:2018-07-06 19:24:14
【问题描述】:
我想更改 GridView 滚动样式以滚动一个部分(如使用 ViewPager)而不是一次滚动一行。 谁能告诉我在不使用任何第三方库的情况下实现此行为的最佳方法是什么?
【问题讨论】:
-
recyclerView 能满足您的需求吗?
标签: android android-gridview android-scroll
我想更改 GridView 滚动样式以滚动一个部分(如使用 ViewPager)而不是一次滚动一行。 谁能告诉我在不使用任何第三方库的情况下实现此行为的最佳方法是什么?
【问题讨论】:
标签: android android-gridview android-scroll
这里有一个post,它解释了如何将 GridView 与水平滚动一起使用,据我所知,如果你想让它作为 ViewPager 工作,你正在努力实现这一目标
基本上你插入 GridView 在 HorizontalScrollView
内 <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>
【讨论】: