HarmonyOS 鸿蒙Next:请问怎么把背景颜色铺满整个屏幕啊?找了很久文档,都没有找到。

发布于 1周前 作者 wuwangju 来自 鸿蒙OS

HarmonyOS 鸿蒙Next:请问怎么把背景颜色铺满整个屏幕啊?找了很久文档,都没有找到。

请问怎么把背景颜色铺满整个屏幕啊?找了很久文档,都没有找到。。。。。


关于HarmonyOS 鸿蒙Next:请问怎么把背景颜色铺满整个屏幕啊?找了很久文档,都没有找到。的问题,您也可以访问:https://www.itying.com/category-93-b0.html 联系官网客服。

8 回复

是要包括顶部状态栏和询问导航栏吗?如果是,则在EntryAbility.ets文件中 onWindowStageCreate()方法内加入开启全屏状态,如果同时还需要显示状态栏和导航栏,则还要开启这两者,并获取两者的尺寸高度,在应用的UI中用padding属性避开这两个区域。方法内加入的代码如下:

 let windowClass: window.Window = 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));
      // 设置主窗口全屏显示。
      windowClass.setWindowLayoutFullScreen(true);
      //显示状态栏, 如需显示导航栏,加入'navigation' 到下面数组中
      windowClass.setWindowSystemBarEnable(['status'], (err) => {
        if (err.code) {
          console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
          return;
        }
        console.info('Succeeded in setting the system bar to be visible.');
      });
      //获取屏幕顶部及询问避开区域(顶部开窗孔,询问导航软按键区)
      let area = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)
      C.top = area.topRect.height;  //状态栏高度
      C.bottom = area.bottomRect.height; //导航栏高度<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 8px; right: 8px; font-size: 14px;">复制</button>

找HarmonyOS工作还需要会Flutter技术的哦,有需要Flutter教程的可以学学大地老师的教程,很不错,B站免费学的哦:https://www.bilibili.com/video/BV1S4411E7LY/?p=17

你好,这些方法都是在ability的windowstage里写的,实现的是首个页面的沉浸式,我要实现内部某个界面的沉浸式该怎么实现呢?也就是说页面内部获取某个页面的 windowStage,

找HarmonyOS工作还需要会Flutter的哦,有需要Flutter教程的可以学学大地老师的教程,很不错,B站免费学的哦:https://www.bilibili.com/video/BV1S4411E7LY/?p=17

我调用的是组件内部的.expandSafeArea安全区域方法,但是上方时间栏那块总是不沉浸

回到顶部