我使用LazyColumninside BottomSheetDialogFragment,但如果LazyColumn向上滚动列表,则Bottom工作表对话框将滚动而不是LazyColumn列表。似乎BottomSheetDialogFragment拦截用户触摸输入。
看起来就是这样:

LazyColumn里面如何正确使用BottomSheetDialogFragment?
MyBottomSheetDialogFragment.kt:
class MyBottomSheetDialogFragment : BottomSheetDialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return ComposeView(requireContext()).apply {
setContent {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Text("Header", color = Color.Black)
LazyColumn(
Modifier
.weight(1f)
.fillMaxWidth()) {
items(100) {
Text("Item $it", Modifier.fillMaxWidth(), Color.Black)
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
并使用以下代码显示它:
MyBottomSheetDialogFragment().show(activity.supportFragmentManager, null)
Run Code Online (Sandbox Code Playgroud)
当我们使用 XMLRecyclerView列表时,要解决这个问题,我们必须使用此处描述的方式包装RecyclerView列表,但是如何使用 Jetpack Compose …
android scroll bottom-sheet android-jetpack-compose lazycolumn
例如,我在应用程序中有 MyBottomSheetDialogFragment 和 Compose LazyColumn 代码:
class MyBottomSheetDialogFragment : BottomSheetDialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return ComposeView(requireContext()).apply {
setContent {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Text("Header", color = Color.Black)
LazyColumn(
Modifier
.weight(1f)
.fillMaxWidth()) {
items(100) {
Text("Item $it", Modifier.fillMaxWidth(), Color.Black)
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
并使用以下代码显示它:
MyBottomSheetDialogFragment().show(activity.supportFragmentManager, null)
Run Code Online (Sandbox Code Playgroud)
这就是我们所拥有的:
MyBottomSheetDialogFragment 屏幕图像.jpg
现在,如果向下滚动 LazyColumn 列表,则一切都会正常工作,但如果向上滚动 LazyColumn 列表,则底部工作表对话框将滚动,而不是 LazyColumn 列表。
如何在 BottomSheetDialogFragment 中正确实现 LazyColumn?
当我们使用 XML RecyclerView 列表时,要解决此问题,我们必须使用 NestedScrollView 包装 RecyclerView 列表,如此处所述 …
android-jetpack-compose android-bottomsheetdialog bottomsheetdialogfragment android-jetpack-compose-list lazycolumn