鸿蒙实现沉浸式全屏模式

实现沉浸式全屏模式有两种方式,可以进行全局设置,也可以在各个页面中进行设置,首先全局设置方式

在EntryAbility中的onWindowStageCreate方法中实现,如下:

  onWindowStageCreate(windowStage: window.WindowStage) {
    // Main window is created, set main page for this ability
    hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');

    // 1.获取应用主窗口。
    let windowClass = null;

    windowStage.getMainWindow((err, data) => {
      if (err.code) {
        console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
        return;
      }
      windowClass = data;
      console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));

      // 2.实现沉浸式效果:设置导航栏、状态栏显示。
      // let names = ['status', 'navigation'];
      // 2.实现沉浸式效果:设置导航栏、状态栏不显示。
      let names = [];
      windowClass.setWindowSystemBarEnable(names, (err) =&

相关推荐

  1. 鸿蒙实现沉浸模式

    2024-03-26 17:32:07       67 阅读
  2. 鸿蒙设置沉浸状态栏、、获取导航栏高度

    2024-03-26 17:32:07       208 阅读
  3. 鸿蒙NEXT】设置

    2024-03-26 17:32:07       89 阅读
  4. 安卓实现沉浸安卓状态栏实现

    2024-03-26 17:32:07       40 阅读
  5. react 显示实现

    2024-03-26 17:32:07       40 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-26 17:32:07       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-26 17:32:07       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-26 17:32:07       87 阅读
  4. Python语言-面向对象

    2024-03-26 17:32:07       96 阅读

热门阅读

  1. 网络问题排查方案

    2024-03-26 17:32:07       36 阅读
  2. 类模板与继承及成员、全局函数的实现

    2024-03-26 17:32:07       86 阅读
  3. 【LeetCode周赛】第 390 场周赛

    2024-03-26 17:32:07       42 阅读
  4. VC++ class wizard介绍

    2024-03-26 17:32:07       34 阅读
  5. 每日一题:C语言经典例题之字符串的比较

    2024-03-26 17:32:07       41 阅读