HarmonyOS 如何全局避让手机底部的导航栏?

HarmonyOS 如何全局避让手机底部的导航栏?

HarmonyOS
2024-10-16 10:13:56
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
put_get

HarmonyOS默认自动避让手机底部导航条,如果设置了setWindowLayoutFullScreen(true)设置了窗口全屏,可以在EntryAbility中获取并存储底部导航条高度:

onWindowStageCreate(windowStage: window.WindowStage) {  
  // Main window is created, set main page for this ability  
  hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');  
  windowStage.loadContent('pages/Index', (err, data) => {  
    if (err.code) {  
      hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');  
      return;  
    }  
    hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');  
    let windowClass = windowStage.getMainWindowSync()  
    let bottomHeight = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect.height  
    AppStorage.setOrCreate('bottomHeight',px2vp(bottomHeight));  
  });  
}

并在需要的界面的最外层布局添加margin ,比如:

column().margin({ bottom: AppStorage.get('bottomHeight') })
分享
微博
QQ
微信
回复
2024-10-16 17:29:46
相关问题
HarmonyOS 获取手机底部导航高度
400浏览 • 1回复 待解决
HarmonyOS Web组件安全避让导航
246浏览 • 1回复 待解决
HarmonyOS 如何获取底部导航高度?
369浏览 • 1回复 待解决
HarmonyOS 怎么去掉底部导航
366浏览 • 1回复 待解决
HarmonyOS 如何让内容超出底部导航
213浏览 • 1回复 待解决
HarmonyOS 手机底部AI导航能否隐藏
307浏览 • 1回复 待解决
HarmonyOS 怎么设置无导航全局样式
252浏览 • 1回复 待解决
Navigation如何隐藏导航
2458浏览 • 1回复 待解决