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

华为设备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
}

疑问

  1. 是否有开发者遇到过类似的华为设备兼容性问题?
  2. 该问题的核心原因是什么?
  3. 如何在应用中修复此偏移问题?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 22:03:16