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

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

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

阅读 699
1 个回答

可以尝试一下沉浸式开发来对导航条进行避让,请参考: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));
  }
});
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进