前言
android Pie 已经发布了,国内大部分手机还处于5.0,6.0,7.0版本。今年主流新机是有8.0的系统。对图标进行适配也到时候了。
1.适配与不适配区别
适配前,海豚记账app
适配后,海豚记账app
2.准备工作
2.1 让ui切透明的图层(512*512 ,带圆角),背景色使用工具调整。
2.2 Android Studio IDE
3.进行调整
File -> New -> Image Asset
需要调整地方
- Foreground Layer 前景icon
- Background Layer 背景
- Path: 通过path 去选择目标Icon
- Scaling: 拖动滑块调整比例
3.1 apply 后会在下面的几个文件夹下自动生成 ic_launcher_foreground.png,ic_launcher_round.png,ic_launcher.png,以及兼容api 26 +文件夹
mipmap-anydpi-v26【 ic_launcher.xml,ic_launcher_round.xml】
这里我们只需要调整 AndroidManifest.
application
android:name=".base.BaseApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:resizeableActivity="false"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
命名即可。至于有人问 android:roundIcon 是干嘛使的,网上说是为了过渡到8.0(背景+图形+蒙版)图标样式的中间版本。兼容6.0+ 的。
3.1 注意事项
第三步,自动生成的 c_launcher.png,会覆盖之前文件夹中同名文件。因为 8.0+ 用自动适配到 mipmap-anydpi-v26中ic_launcher. 建议mdip-xxx,里面的 c_launcher.png,仍然沿用之前的图标。
因为自动生成的图标不太符合要求啊。
引用 官网 https://developer.android.google.cn/about/versions/oreo/android-8.0-changes
8.0 系统适配 https://blog.csdn.net/u010888665/article/details/81709569