在自由窗口状态下同时配置fullscreen和split时,如果应用的targetAPIVersion小于15,窗口将以悬浮窗模式启动;如果应用的targetAPIVersion大于等于15,窗口将以全屏模式启动。此外,还可以通过metadata配置窗口模式,具体的配置规则和优先级请参考metadata。
示例代码如下:
"abilities": [
{
"name": "EntryAbility",
"srcEntry": "./ets/entryability/EntryAbility.ets",
"description": "$string:EntryAbility_desc",
"icon": "$media:layered_image",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:startIcon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
// 设置窗口模式:禁用分屏配置["fullscreen","floating"],禁用悬浮窗配置["fullscreen","split"],只全屏配置["fullscreen"]
// 以下以禁用分屏为例,其他场景按上述配置
"supportWindowMode": ["fullscreen","floating"],
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"ohos.want.action.home"
]
}
]
}
], Q:为何avoidAreaChange监听在悬浮窗时获取到的都是0?
A:需要排查监听避让区的方式是否正确,window.AvoidAreaType.TYPE_CUTOUT表示挖孔区域,window.AvoidAreaType.TYPE_SYSTEM表示悬浮窗下的三点控制栏区域,详情参考AvoidAreaType。