HarmonyOS 升级api12后,安全区域的背景图片无法覆盖

背景图片backgroundImage的设置无法覆盖满屏幕,底部会有留白。但是使用backgroundColor设置的颜色能覆盖满屏幕,如何解决?

如果想在获取安全区域高度,如在样式中希望paddingBottom: SafeAreaEdge.BOTTOM,应该如何实现?

HarmonyOS
2024-12-24 16:07:30
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

可以尝试一下沉浸式开发来对导航条进行避让,请参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-develop-apply-immersive-effects-V5#section202484117114可以通过getWindowAvoidArea来获取安全区域高度。

import { window } from '@kit.ArkUI'
import { BusinessError } from '@ohos.base';
import { common } from '@kit.AbilityKit';
let context = getContext(this) as common.UIAbilityContext
let windowClass: window.Window | undefined = undefined;
window.getLastWindow(context, (err: BusinessError, data) => {
  const errCode: number = err.code;
  if (errCode) {
    console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
    return;
  }
  windowClass = data;
  let type = window.AvoidAreaType.TYPE_SYSTEM;
  try {
    let avoidArea = windowClass.getWindowAvoidArea(type);
    console.log(JSON.stringify(avoidArea))
  } catch (exception) {
    console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception));
  }
});
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
分享
微博
QQ
微信
回复
2024-12-24 18:50:35
相关问题
HarmonyOS 安全区域问题
1038浏览 • 1回复 待解决
HarmonyOS 安全区域出错
837浏览 • 1回复 待解决
HarmonyOS 安全区域失效
814浏览 • 1回复 待解决
HarmonyOS 视频组件无法扩展其安全区域
1141浏览 • 1回复 待解决
HarmonyOS 设置安全区域不生效
894浏览 • 1回复 待解决
HarmonyOS WebView安全区域问题
648浏览 • 1回复 待解决
HarmonyOS scroll安全区域问题
906浏览 • 1回复 待解决
HarmonyOS 页面底部流出安全区域
908浏览 • 1回复 待解决
HarmonyOS 背景图片如何填充满组件
1613浏览 • 1回复 待解决
关于屏幕安全区域问题咨询
1130浏览 • 1回复 待解决
HarmonyOS 如何获取手机安全区域高度
851浏览 • 1回复 待解决