我在布局中直接使用RecyclerView时遇到了一个问题,那就是底表行为。问题是,当底部工作表展开,内容向下滚动时,当我向上滚动时,它会导致底部工作表开始折叠,而不是RecyclerView首先滚动回到顶部。
这里有一个video来演示这个问题。正如你所看到的,当我向下滚动展开的底部页面时,问题出现了。它立即开始崩溃,而不是“等待”RecyclerView滚动到顶部。
这是我的布局代码
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
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:id="@+id/scheduleRoot"
android:layout_height="match_parent"
tools:context=".schedule.ScheduleFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scheduleSheet"
app:behavior_peekHeight="300dp"
android:elevation="16dp"
android:clickable="false"
android:focusable="false"
android:background="@drawable/bg_bottom_sheet"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scheduleRecyclerView"
android:clickable="true"
android:focusable="true"
android:layout_marginTop="8dp"/>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>如有任何帮助,我们不胜感激!
发布于 2020-11-30 07:00:26
我刚刚遇到了同样的问题,但我通过将以下代码添加到onCreate来修复它:
androidx.core.view.ViewCompat.setNestedScrollingEnabled(recyclerview, false);发布于 2020-07-01 17:44:22
您的回收视图项目已覆盖滚动状态,因此生成此错误。您提供的布局没有足够的数据来确定原因。您更改的项目是要检查的唯一视图
发布于 2021-07-16 19:15:50
我也有类似的问题:也许我的问题的解决方案会给你一些想法。我的底部工作表展开到全高,回收器视图在其中;用户拖动时,底部工作表正在折叠,即使回收器视图中的第一个项目还不可见。
所以,我所做的是:
<代码>G29
也许它不是最优的,但它满足了我的需求,也许会对你有所帮助。
https://stackoverflow.com/questions/56012918
复制相似问题