aboutToAppear(): void {
window.getLastWindow(this.getUIContext().getHostContext())
.then(win => {
win.setWindowLayoutFullScreen(true); // 设置全屏
})
} 当应用调用setWindowLayoutFullScreen接口设置窗口全屏布局时,未使用setSpecificSystemBarEnabled方法对系统导航栏进行隐藏,也未使用setWindowSystemBarProperties将导航栏颜色等属性与界面元素进行匹配。
参考沉浸式页面实现实现页面沉浸式适配。
若需单独控制状态栏或导航栏的显示与隐藏,可在EntryAbility的onWindowStageCreate生命周期回调中调用setSpecificSystemBarEnabled接口进行设置:
import { window } from '@kit.ArkUI';
onWindowStageCreate(windowStage: window.WindowStage): void {
let windowClass: window.Window = windowStage.getMainWindowSync();
if (!windowClass) {
console.info('windowClass is null');
return;
}
try {
windowClass.setSpecificSystemBarEnabled('status', false); // 隐藏状态栏
windowClass.setSpecificSystemBarEnabled('navigationIndicator', false); // 隐藏导航条
} catch (exception) {
console.error(`Failed to set specific system bar enabled. Cause: ${JSON.stringify(exception)}`);
}
windowStage.loadContent('pages/Index', (err) => {
// ...
});
}