图标资源规范
为保证图标在系统内显示的一致性,应用预置的图标资源应满足以下要素:
- 图标资源必须为分层资源(分为foreground、background)
- 图标资源尺寸必须为1024*1024px
- 图标资源必须为为正方形图像,系统会为对应场景自动生成遮罩裁切
- 图标资源建议使用PNG格式
修改应用图标/名称
在项目 AppScope/resources/base/element/string.json 目录下可以看到:
javascript
{
"app": {
"bundleName": "com.example.myapplication",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"buildVersion": "1",
"icon": "$media:layered_image",
"label": "$string:app_name"
}
}
在项目 src/main/module.json5 目录下可以看到:
javascript
"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,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"ohos.want.action.home"
]
}
]
}
],
其中 icon 和 label 字段分别对应了应用的图标/名称。
图标 icon 的位置位于项目目录 src/main/resources/base/media/layered_image.json 以及 AppScope/resources/base/media/layered_image.json 文件:
javascript
{
"layered-image":
{
"background" : "$media:background",
"foreground" : "$media:foreground"
}
}
javascript
{
"layered-image":
{
"background" : "$media:background",
"foreground" : "$media:foreground"
}
}
这里的 background 和 foreground 字段分别对应应用图标的背景/前景图,存放于当前目录(media)下。注意命名要对应。
需要特别注意的是,图片的背景图
background必须是一张正方矩形,不应该有透明区域。
名称 label 的位置位于项目目录 src/main/resources/base/element/string.json 文件:
javascript
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "label"
}
]
}
这里的 EntryAbility_label 字段对应的值即为应用所显示的名称,修改这一项即可。