为应用设置 ICON 图标

操作步骤

  1. 准备好应用图标图片文件
  2. 将图标放到 Resources/drawable 或者 Resources/mipmap‑xxx 目录下
  3. 打开 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)
  1. 图标资源文件名只能小写、数字、下划线,不能用中文、空格
  2. icon 是必备;roundIcon 高版本安卓用于桌面圆形图标
  3. 图标放置推荐放mipmap系列文件夹,系统会根据手机分辨率自动选用对应尺寸
  4. Xamarin.Android也可以在Activity特性设置图标,但全局App图标以Manifest里面application节点为准

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注