鸿蒙开发中适配横竖屏模式(只适配折叠屏不影响手机)
·
本人在鸿蒙开发上架图中遇到了如下问题
因此去查找相关的资料去解决这个问题
"abilities": [
{
"name": "EntryAbility",
"srcEntry": "./ets/entryability/EntryAbility.ets",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:startIcon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "auto_rotation", // 随传感器旋转
}
]
我找到了如下教程,让我在module.json5添加属性"orientation": "auto_rotation“,可以适配的相关的自动旋转屏幕的功能(但是是都适配),所以我去查找相关的函数发现,这个里面是留出来了
"orientation": "follow_desktop",这个策略能自动根据设备类型采用不同的默认行为:在直板手机和折叠屏的折叠态上使用竖屏,在平板和折叠屏的展开态上则允许屏幕旋转。

这样即可解决相关的问题!
更多推荐



所有评论(0)