BottomSheetDialogFragment - 允许子视图滚动

38

我有一个带有RecyclerViewBottomSheetDialogFragment。问题是,只要RecyclerView没有向上滚动,我想禁用BottomSheetDialogFragment的拖动关闭功能(当前我无法滚动RecyclerView,因为尝试滚动将始终关闭BottomSheetDialogFragment)。有什么办法可以实现这一点吗?


您可以将NestedScrollView用作RecyclerView的父级,这可能会有所帮助。 - Ajith Pandian
1
<fragment><NestedScrollView><RecyclerView/></NestedScrollView></fragment> - Ajith Pandian
1
这并没有帮助。而且 RecyclerView 已经支持作为一个嵌套滚动视图了... - prom85
有找到这个问题的解决方案吗?@prom85 - Morteza Rastgoo
你找到任何解决方案了吗?如果有,请分享一下。 - K Pradeep Kumar Reddy
13个回答

0
只需将您的布局包装在NestedScrollView中,并将此属性添加到RecyclerView中。
android:nestedScrollingEnabled="true"

-1

使用约束布局

<androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_team_mates"
            android:layout_width="@dimen/dp_0"
            android:layout_height="@dimen/dp_0"
            android:layout_marginVertical="@dimen/dp_20"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/txt_title_custom"
            app:layout_constraintBottom_toBottomOf="parent"/>

3
请在您的回答中提供更多细节。目前的写法让人难以理解您的解决方案。 - Community

-4
将您的RecyclerView放置在NestedScrollView下面,其中NestedScroll是recycler的父级。

这不会有任何区别,仍然关闭片段!! - Mohamed Elnady

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接