操作步骤
- 准备好应用图标图片文件
- 将图标放到
Resources/drawable或者Resources/mipmap‑xxx目录下 - 打开
AndroidManifest.xml,修改<application>标签的图标相关属性
mipmap目录专门存放App启动图标,区分不同屏幕分辨率;drawable更多放普通界面图片。
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">Code language: HTML, XML (xml)
属性说明
android:icon:普通应用图标,所有安卓版本通用android:roundIcon:圆形图标,Android7.0及以上系统会优先使用这个圆形图标android:label="@string/app_name":桌面显示的应用名称,引用字符串资源
更换自定义图标示例
把图标文件 my_app_icon.png 放入 Resources/mipmap
<application
android:allowBackup="true"
android:icon="@mipmap/my_app_icon"
android:roundIcon="@mipmap/my_app_icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">Code language: HTML, XML (xml)
- 图标资源文件名只能小写、数字、下划线,不能用中文、空格
icon是必备;roundIcon高版本安卓用于桌面圆形图标- 图标放置推荐放
mipmap系列文件夹,系统会根据手机分辨率自动选用对应尺寸- Xamarin.Android也可以在Activity特性设置图标,但全局App图标以Manifest里面application节点为准
Previous: 资源 Resources
Next: 播放一首歌(MediaPlayer)