【鸿蒙NEXT】设置全屏

打印 上一主题 下一主题

主题 1015|帖子 1015|积分 3045

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
EntryAbility.ets

  1. onWindowStageCreate(windowStage: window.WindowStage): void {
  2.     EntryAbility.windowStage = windowStage
  3.     // Main window is created, set main page for this ability
  4.     this.requestFullScreen(windowStage, this.context)
  5.     windowStage.loadContent('pages/Index', (err, data) => {
  6.       if (err.code) {
  7.         hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
  8.         return;
  9.       }
  10.       hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
  11.     });
  12.   }
  13.   
  14.   private requestFullScreen(windowStage: window.WindowStage, context: Context) {
  15.     try {
  16.       let windowClass = windowStage.getMainWindowSync()
  17.       let area = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)
  18.       if (area.topRect.height > 0) {
  19.         DeviceInfoUtils.setStatusBarHeight(area.topRect.height)//存储状态栏高度
  20.         windowClass.setWindowLayoutFullScreen(true)
  21.       }
  22.     } catch (err) {
  23.       console.error(`requestFullScreen err = ${err}`)
  24.     }
  25.   }
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

没腿的鸟

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表