华为设备Jetpack Compose下底部导航与ModalBottomSheetDialog偏移问题求助
华为设备上Compose底部导航与ModalBottomSheetDialog偏移问题
问题背景
重构旧实现方案后,QA反馈华为设备上底部导航及其下方的ModalBottomSheetDialog出现偏移问题——弹窗整体下移,但该问题在Pixel 7、Samsung A13设备及模拟器上均未出现。
当前布局内边距设置
Scaffold( ... }, contentWindowInsets = WindowInsets(0,0,0,0) ) { localPadding -> NavHost( modifier = Modifier .padding(paddingValues = localPadding) .consumeWindowInsets(paddingValues = localPadding) .windowInsetsPadding( WindowInsets.safeDrawing.only( WindowInsetsSides.Horizontal, ), ) .systemBarsPadding(), navController = navController, startDestination = startDestination ) { ...
设备表现差异
- 华为设备:底部导航与弹窗整体下移,弹窗顶部与底部导航之间存在明显间距
- Samsung A13设备:底部导航与弹窗布局正常,弹窗顶部贴合底部导航
2023年12月1日更新
当前使用Compose BOM: 2023.10.01,目前采用的BottomSheet写法如下:
ModalBottomSheet( modifier = Modifier.fillMaxHeight(), sheetState = sheetState, onDismissRequest = { }, windowInsets = WindowInsets.ime .union(WindowInsets.statusBars) .union(WindowInsets.navigationBars) ) { // content here }
疑问
- 是否有开发者遇到过类似的华为设备兼容性问题?
- 该问题的核心原因是什么?
- 如何在应用中修复此偏移问题?
内容的提问来源于stack exchange,提问作者exndy
相关产品推荐
相关产品推荐

