1、全屏:全局设置
在 EntryAbility.ts 中 onWindowStageCreate方法设置
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
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) ?? '');
// 设置全屏
windowStage.getMainWindow((error,window)=>{
window.setWindowLayoutFullScreen(true)
// 隐藏状态栏
window.setWindowSystemBarEnable(['navigation'])
})
});
}
2、全屏:局部设置
import window from '@ohos.window';
onPageShow() {
window.getLastWindow(getContext(this), (err, windowBar) => {
windowBar.setWindowLayoutFullScreen(true)
// 隐藏状态栏
windowBar.setWindowSystemBarEnable(['navigation'])
})
}