【发布时间】:2017-12-05 18:48:11
【问题描述】:
我有两个嵌套的RecyclerView。其中之一管理垂直滑动,其中之一处理水平滑动。我面临的问题是,水平 RecyclerView 的滚动有时不会按预期运行。有时它不会识别水平滑动,只会进行垂直滑动。要进行水平滑动,必须在水平方向上画一条真正的直线。偏离几度将被识别为垂直滑动。是否可以调整任何参数以使用户体验更好?
外部布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:gravity="center">
<ProgressBar
android:id="@+id/pb_new_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_modules"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:nestedScrollingEnabled="false"
android:paddingBottom="@dimen/newhome_recyclerview_paddingbottom" />
</RelativeLayout>
内部布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/NewHomeModuleContainer">
<TextView
android:id="@+id/tv_module_title"
style="@style/NewHomeModuleTitle" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_horizontal_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/tv_show_more"
android:layout_below="@id/tv_module_title"
android:layout_marginBottom="-8dp"
android:clipToPadding="false"
android:paddingEnd="28dp"
android:paddingRight="28dp" />
</RelativeLayout>
【问题讨论】:
-
其实有点复杂,不知道能不能说清楚。但基本上我们有一个代理作为外部模块的适配器,它根据 json 类型实例化不同的模块。每个垂直模块创建另一个 ViewHolder 与自定义 View 和可能另一个 RecyclerView
标签: android android-recyclerview