美文网首页
记HarmonyOS FA 半屏Ability拉起全屏Abili

记HarmonyOS FA 半屏Ability拉起全屏Abili

作者: 蜗牛学开车 | 来源:发表于2022-11-24 13:51 被阅读0次

    关于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拉起全屏Abili

          本文链接:https://www.haomeiwen.com/subject/mhqxfdtx.html