You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JetPack Compose BottomSheetDialog:添加rememberNestedScrollInteropConnection后标题无法触发弹窗最小化

解决方案

问题根源是你把nestedScroll修饰符加在了整个Column上,这会拦截所有区域的滚动触摸事件,包括标题栏的拖拽操作,导致弹窗无法响应最小化指令。

只需要将嵌套滚动修饰符仅应用在LazyColumn上,让标题区域保留原生触摸交互即可解决问题:

ComposeView(requireContext()).apply {
    setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
    setContent {
        Theme {
            Column { // 移除Column上的nestedScroll修饰符
                Row {
                    Text(
                        modifier = Modifier
                            .padding(16.dp)
                            .fillMaxWidth(),
                        text = "Title"
                    )
                }
                LazyColumn(
                    Modifier
                        .weight(1f)
                        .fillMaxWidth()
                        .nestedScroll(rememberNestedScrollInteropConnection()) // 仅给列表添加嵌套滚动
                ) {
                    items(100) {
                        Text(
                            text = "Item $it",
                            modifier = Modifier
                                .padding(16.dp)
                                .fillMaxWidth(),
                        )
                    }
                }
            }
        }
    }
}

效果验证

  • 列表向下滚动后再向上滚动,只会触发列表自身滚动,不会带动弹窗最小化
  • 触摸标题栏拖拽,可正常触发弹窗的最小化操作
  • 弹窗的最大化、关闭等原有交互逻辑不受影响

内容的提问来源于stack exchange,提问作者Joao

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 02:57:31