EntryAbility.ets
onWindowStageCreate(windowStage: window.WindowStage): void {
EntryAbility.windowStage = windowStage
// Main window is created, set main page for this ability
this.requestFullScreen(windowStage, this.context)
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) ?? '');
});
}
private requestFullScreen(windowStage: window.WindowStage, context: Context) {
try {
let windowClass = windowStage.getMainWindowSync()
let area = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)
if (area.topRect.height > 0) {
DeviceInfoUtils.setStatusBarHeight(area.topRect.height)//存储状态栏高度
windowClass.setWindowLayoutFullScreen(true)
}
} catch (err) {
console.error(`requestFullScreen err = ${err}`)
}
}
文章来源地址https://www.toymoban.com/news/detail-852769.html
文章来源:https://www.toymoban.com/news/detail-852769.html
到了这里,关于【鸿蒙NEXT】设置全屏的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!