Android 选项卡、具有水平和垂直滚动的列表视图?
我需要创建一个屏幕(活动/片段),其中包含列表中的项目(平铺),可以水平和垂直滚动+选项卡。类似于Google Play的主页。 请参见屏幕截图: 这方面的最佳解决方案是什么?可能会建议一些好的库/组件。Android 选项卡、具有水平和垂直滚动的列表视图?,android,Android,我需要创建一个屏幕(活动/片段),其中包含列表中的项目(平铺),可以水平和垂直滚动+选项卡。类似于Google Play的主页。 请参见屏幕截图: 这方面的最佳解决方案是什么?可能会建议一些好的库/组件。 谢谢。您可以分步骤执行此操作 创建顶部选项卡 在“主页”选项卡中,使用自定义视图创建一个列表视图 为此列表创建一个自定义适配器,并用另一个水平遍历的列表填充listview的每一行 因此,您将有两个列表,第一个垂直遍历,第二个将填充到第一个列表的行中并水平遍历 尝试解决这个问题,然后在遇到b
谢谢。您可以分步骤执行此操作
列表视图李>
为此列表创建一个自定义适配器,并用另一个水平遍历的列表填充listview的每一行李>
因此,您将有两个列表,第一个垂直遍历,第二个将填充到第一个列表的行中并水平遍历
尝试解决这个问题,然后在遇到bug时更新这个问题
希望这有帮助:)这里有更好的方法
创建一个
使用线性布局
制造
用水平
滚动放置卡片,并为每行制作卡片
重复步骤3和4
享受。这真的很简单。您只需在父级中将“nestedScrollingEnabled”标志设置为true。关于如何使用scrollview作为根布局在xml中执行此操作的一个非常高级的示例:
--滚动视图
------RelativeLayout//as scrollview只能有一个子项
---------RecyclerView1-->将LayoutManager设置为水平
---------RecyclerView2-->将LayoutManager设置为水平
-------EndRelativeLayout
--EndScrollView
这对我适用(您可以忽略@id/headers部分):
至少建议使用RecyclerView
而不是ListView
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/next"
android:nestedScrollingEnabled="true"
tools:ignore="MissingPrefix">
<TextView
android:id="@+id/header1"
fontPath="fonts/CircularStd-Bold.otf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:text=""
android:textSize="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/header2"
fontPath="fonts/CircularStd-Bold.otf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:text=""
android:textSize="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recycler_view_2" />
<TextView
android:id="@+id/textView26"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:paddingBottom="100dp"
android:text=""
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recycler_view_1" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@+id/header1"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollbars="none"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/header2" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@+id/header1"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollbars="none"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/header1" />
</android.support.constraint.ConstraintLayout>
</ScrollView>