Android 中添加嵌套片段时 BottomSheetDialogFragment 行为紊乱

BottomSheetDialogFragment behaviour disorder when added nested fragment in Android

我在 RecyclerView 中有一个 BottomSheetDialogFragment,单击时会显示 BottomSheet 按钮。 BottomSheetDialog 在向下滚动时展开,在正常滚动到顶部时折叠。

但是当我将 RecyclerView 放入片段中并将片段放置到 BottomSheetDialog 时; BottomSheet 行为不适用于片段,仅适用于 RecyclerView 滚动。另一方面,这些行为在 BottomSheet 的其他地方起作用。如何启用第一个中的行为?

您应该检查您的容器布局是否有 app:layout_behavior="@string/bottom_sheet_behavior"> 并检查您定义的任何 listener/event 额外的内容,否则 BottomSheetDialog 通常会按您预期的方式运行。