我在布局内直接使用具有bottomsheetbehaviour 的RecyclerView 时遇到问题。问题是,当底部工作表展开并且内容向下滚动时,当我向上滚动时,它会导致底部工作表开始折叠,而不是 RecyclerView 首先滚动回顶部。
这是演示该问题的视频。正如您所看到的,当我在展开的底部工作表上向下滚动时,问题出现了。它立即开始折叠,而不是“等待”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>
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏!
小智 -2
您的实现可能需要更多编码,并且使用所提供的代码,我们可能无法为您提供良好的反馈。
试试这个文档 https://material.io/develop/android/components/bottom-sheet-behavior/
另外我发现了另一个实现。 https://www.youtube.com/watch?v=WeaylHAwIIk
归档时间: |
|
查看次数: |
12770 次 |
最近记录: |