第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

HarmonyOS NEXT 使用AppStorageV2實(shí)現(xiàn)全屏展示

鸿蒙原生开发中,为了实现沉浸式效果,通常在页面中通过设置expandSafeArea属性向顶部和底部扩展安全区实现沉浸式效果,.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]);设置完成后,发现没有实现想要的效果,就需要点击ArkUI Inspector查看当前展示试图层级中,哪些试图没有实现沉浸式,在到代码中添加expandSafeArea属性

这种实现方式仅限于整个应用中个别页面需要沉浸式效果,其他大部分页面都要展示安全区。

如果整个应用大部分页面都需要沉浸式效果,就可以在entryAbility中统一设置窗口全屏展示,这个时候我们需要声明一个宽高的对象类来存储在AppStorageV2中,然后调用AppStorageV2的connect方法直接储存,并将生成的对象全局化,这样在对对象的属性进行修改时,就可以通过到AppStorageV2中了private deviceRect: GRDeviceInfo = AppStorageV2.connect(GRDeviceInfo , () => new GRDeviceInfo ())!;

下面是具体代码示例:

import { AppStorageV2, window } from '@kit.ArkUI';
import { GRDeviceInfo } from '../utils/GRDeviceInfo';

export class GRDeviceInfo {
  topRectHeight: number = 0;
  bottomRectHeight: number = 0;
}

private deviceRect: GRDeviceInfo = AppStorageV2.connect(GRDeviceInfo, () => new GRDeviceInfo())!;

let windowClass: window.Window = windowStage.getMainWindowSync();
let isLayoutFullScreen = true;
windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => {
  console.info('Succeeded in setting the window layout to full-screen mode.');

  windowStage.loadContent('pages/Index', (err) => {
    // windowStage.loadContent('pages/welcome/DDWelcomePage', (err) => {
    if (err.code) {
      console.error(TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
      return;
    }
    console.info(TAG, 'Succeeded in loading the content.');
  });

}).catch((err: BusinessError) => {
  console.info(TAG,'Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err));
});

//获取导航栏高度
this.deviceRect.bottomRectHeight = windowClass
  .getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR)
  .bottomRect
  .height;
// 获取状态栏区域高度
this.deviceRect.topRectHeight = windowClass
  .getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)
  .topRect
  .height;
// 注册监听函数,动态获取避让区域数据
windowClass.on('avoidAreaChange', (data) => {
  if (data.type === window.AvoidAreaType.TYPE_SYSTEM) {
    this.deviceRect.topRectHeight = data.area.topRect.height;
  } else if (data.type == window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) {
    this.deviceRect.bottomRectHeight = data.area.bottomRect.height;
  }
});

----------------- end ---------------

后面会继续补充不足之处。

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫(xiě)下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消