鸿蒙学习 - 沉浸式设置setWindowLayoutFullScreen

75 阅读1分钟

鸿蒙学习 - 沉浸式设置setWindowLayoutFullScreen

特别提醒:setWindowLayoutFullScreen在模拟器上有卡死的bug,真机没有问题。 希望后面的版本会更新修复这个bug

// 可以在某个页面设置沉浸式和非沉浸式
async  aboutToAppear() {
  let win = await window.getLastWindow(getContext())
  // 设置全屏 import window from '@ohos.window';
  // await win.setWindowLayoutFullScreen(true) // 设置沉浸式全面屏,会在模拟器卡死,真机没问题,真是坑人的bug
  let area = win.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)
  let topHeight = area.topRect.height
  let topVpheight = px2vp(topHeight)
  console.log("顶部安全区域高度 =  ",topVpheight)

}