HarmonyOS 鸿蒙Next 获取底部安全高度,bottomRect.height为0
HarmonyOS 鸿蒙Next 获取底部安全高度,bottomRect.height为0
onWindowStageCreate(windowStage: window.WindowStage): void {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
let windowClass: window.Window = windowStage.getMainWindowSync();
let area = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)
let statusBarHeight = area.topRect.height
let bottomMargin = area.bottomRect.height;
AppStorage.setOrCreate('statusBarHeight', statusBarHeight)
AppStorage.setOrCreate('safeBottom', bottomMargin)
console.log('area11',JSON.stringify(area))
console.log('statusBarHeight',statusBarHeight)
console.log('bottomMargin',bottomMargin)
windowStage.loadContent('pages/Index', (err) => {
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.');
// 设置全屏
windowClass.setWindowLayoutFullScreen(true);
});
}
更多关于HarmonyOS 鸿蒙Next 获取底部安全高度,bottomRect.height为0的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
2 回复
使用下面的类型。
windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR)
TYPE_NAVIGATION_INDICATOR为底部导航条,TYPE_SYSTEM为系统状态栏
更多关于HarmonyOS 鸿蒙Next 获取底部安全高度,bottomRect.height为0的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html