鸿蒙Next闪屏页在哪里设置?
鸿蒙Next闪屏页在哪里设置? 【设备信息】Mate60
【API版本】Api13
【DevEco Studio版本】5.0.7.200
【问题描述】
进入应用的闪屏页在哪里设置?有文档么?
闪屏页需要在module.json5配置文件的abilities标签中通过startWindowIcon和startWindowBackground设置
"startWindowIcon": "$media:icon", // UIAbility组件启动页面图标资源文件的索引
"startWindowBackground": "$color:start_window_background", // UIAbility组件启动页面背景颜色资源文件的索引
目前startWindowIcon启动图居中按图片像素大小居中显示。如果想设置全屏图可以通过: display.getDefaultDisplaySync().width display.getDefaultDisplaySync().height 获取屏幕宽高,然后准备一张屏幕宽高尺寸的图片。 以Mate 60 Pro为例,为1260*2720像素。
https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/uiability-overview-V5#
在resources目录新建tablet、phone等资源目录,放置startWindowIcon和startWindowBackground对应的资源,则在平板、手机不同产品上显示不同的启动页内容
参考资源访问与分类 https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/resource-categories-and-access-V5
更多关于鸿蒙Next闪屏页在哪里设置?的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
在鸿蒙Next中,闪屏页的设置可以通过config.json
文件进行配置。具体步骤如下:
- 打开项目的
config.json
文件。 - 在
"module"
节点下找到"abilities"
数组。 - 在
"abilities"
数组中,找到你想要配置闪屏页的"ability"
节点。 - 在
"ability"
节点下添加或修改"launchType"
字段,将其值设置为"standard"
或"singleton"
,视具体需求而定。 - 在
"ability"
节点下添加或修改"metaData"
字段,在"metaData"
中添加"customizeData"
,并设置"name"
为"hwc-theme"
,"value"
为"android:windowBackground"
,"extra"
为闪屏页的图片资源路径。
例如:
{
"module": {
"abilities": [
{
"name": ".MainAbility",
"launchType": "standard",
"metaData": {
"customizeData": [
{
"name": "hwc-theme",
"value": "android:windowBackground",
"extra": "$media:splash_screen"
}
]
}
}
]
}
}
在上述示例中,"extra"
字段的值为"$media:splash_screen"
,表示闪屏页的图片资源路径。你可以根据实际情况修改为你的图片资源路径。