记HarmonyOS FA 半屏Ability拉起全屏Ability时状态栏适配的问题

关于Ability的半屏、全屏等模式的配置请参考我另一篇文章:HarmonyOS(鸿蒙)应用/服务开发window_modal配置说明。这里就不在赘述了。

我在开发鸿蒙FA应用时遇到通过半屏Ability拉起全屏Ability时,如果window_modal为0,则全屏Ability会没有状态栏(状态栏为透明,能看到桌面壁纸)的情况。如果window_modal为2则会出现状态栏颜色无法自定义的问题(尤其是在dark模式下不能忍受)。

经过排查是由于需要全屏的Ability在config.json中没有配置metaData导致的:

原来的配置

{
  "visible": true,
  "name": "com.baidu.testApp.ConnectHelperAbility",
  "configChanges": ["orientation"],
  "icon": "$media:icon",
  "description": "$string:empty_description",
  "label": "$string:device_ConnectHelperAbility",
  "type": "page",
  "launchType": "standard"
}

增加

"metaData": {
    "customizeData": [
        {
              "name": "hwc-theme",
              "value": "androidhwext:style/Theme.Emui.Light.NoTitleBar"
        }
     ]
}

最终为下面这样则可以解决

{
  "visible": true,
  "name": "com.baidu.testApp.ConnectHelperAbility",
  "configChanges": ["orientation"],
  "icon": "$media:icon",
  "description": "$string:empty_description",
  "label": "$string:device_ConnectHelperAbility",
  "type": "page",
  "launchType": "standard",
  "metaData": {
    "customizeData": [
      {
        "name": "hwc-theme",
        "value": "androidhwext:style/Theme.Emui.Light.NoTitleBar"
      }
    ]
  }
}

你可能感兴趣的:(记HarmonyOS FA 半屏Ability拉起全屏Ability时状态栏适配的问题)