可以在全屏模式下,窗口和状态栏存在重叠,可通过window的AvoidAreaType获取状态栏和窗口重叠区域的属性。1.通过window的window.getLastWindow获取当前窗口。2.通过当前窗口实例调用getWindowAvoidArea获取状态栏和窗口重叠区域的属性,此区域的高度即为状态栏的高度。示例代码//获取当前窗口 let windowClass = await window.getLastWindow(getContext(this)); //如果没设置全屏就需要设置全屏(非全屏状态下窗口和系统状态栏没有重叠) await windowClass.setWindowLayoutFullScreen(true) let type = window.AvoidAreaType.TYPE_SYSTEM; try { let avoidArea = windowClass.getWindowAvoidArea(type); console.log("height: " + avoidArea.topRect.height) } catch (exception) { console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception)); }参考链接获取窗口内容规避的区域
可以在全屏模式下,窗口和状态栏存在重叠,可通过window的AvoidAreaType获取状态栏和窗口重叠区域的属性。
1.通过window的window.getLastWindow获取当前窗口。
2.通过当前窗口实例调用getWindowAvoidArea获取状态栏和窗口重叠区域的属性,此区域的高度即为状态栏的高度。
示例代码
参考链接
获取窗口内容规避的区域