1.获取应用窗口
let windowClass: window.Window = windowStage.getMainWindowSync(); // 获取应用主窗口
2.注册监听函数,动态获取避让区域数据
windowClass.on('avoidAreaChange', (data) => {
// 判断当前变化的避让区域类型是否为系统避让区域
if (data.type === window.AvoidAreaType.TYPE_SYSTEM) {
// 获取系统避让区域的高度并存储
let topRectHeight = data.area.topRect.height;
LogUtil.info('状态栏高度:',topRectHeight.toString())
AppStorage.setOrCreate(Keys.topRectHeight, topRectHeight);
} else if (data.type == window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) {
// 获取导航条避让区域的高度并存储
let bottomRectHeight = data.area.bottomRect.height;
LogUtil.info('导航栏高度:',bottomRectHeight.toString())
AppStorage.setOrCreate(Keys.bottomRectHeight, bottomRectHeight);
}
});
772

被折叠的 条评论
为什么被折叠?



