gpt4 book ai didi

android - BottomSheet 中的 RecyclerView 未按预期工作

转载 作者:行者123 更新时间:2023-12-04 14:20:00 35 4
gpt4 key购买 nike

我在底部表行为的布局内直接使用 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>

任何帮助表示赞赏!

最佳答案

我刚刚遇到了同样的问题,但我通过将其添加到 onCreate 来修复它:

androidx.core.view.ViewCompat.setNestedScrollingEnabled(recyclerview, false);

关于android - BottomSheet 中的 RecyclerView 未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56012918/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com