android - 如何在具有平滑滚动的同一布局中拥有两个 recyclerview(先水平然后垂直)
问题描述
我在同一个布局中有两个 recyclerview(首先是水平的,然后是垂直的),我希望两者一起向上滚动,所以我使用了 NestedScrollView,但它带来了一些严重的滚动问题。它滞后并导致崩溃一段时间。
我已经看到一些人建议nestedScrollingEnabled = "false"
在 RecyclerView 中使用,但我已经尝试过,但仍然没有结果。
关于如何实现这一目标的任何想法?
这是xml顺便说一句
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/appbar"
android:clipToPadding="false"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/stories_recycler_view"
storiesData="@{viewModel.stories}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_story" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/posts_recycler_view"
feedListData="@{viewModel.entries}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:orientation="vertical"
app:stackFromEnd="true"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:paddingBottomSystemWindowInsets="@{true}"
app:paddingTopSystemWindowInsets="@{true}"
app:reverseLayout="true"
tools:listitem="@layout/item_text_post" />
</LinearLayout>
解决方案
<androidx.core.widget.NestedScrollView
android:id="@+id/nested_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout>
...
Add `android:nestedScrollingEnabled="true"` in both Recyclerview Tag...<br>
...
</LinearLayout>
<androidx.core.widget.NestedScrollView/>
推荐阅读
- apache - Shibboleth 属性未映射
- node.js - 如何从私有 Azure Blob 存储容器中删除 Blob
- sql - 将 NULL 值插入 INT & STRING 列
- c++ - 单引号在 C++ 数学编程中是什么意思?
- sql - 由于“ORDER BY”在视图定义中不起作用,我们如何在 db2 视图中对数据进行排序?
- javascript - Rails,webpacker:在哪里/何时在类中使用 import 语句,以及在 pack/application.js 中要求的目的是什么?
- reactjs - 手动部署收到错误“app.json 必须包含 JSON 对象”
- jenkins - Jenkins 作业无法将 tar 文件推送到 s3 存储桶
- python - 如何从python中的同一个大列表中制作项目对
- python - 如何使用 Selenium 抓取 innerHTML 以获取 NFL 投注数据?