feat: 新增 Adaptive Icon(anydpi-v26),修复 API 26+ 启动器裁切
问题
- minSdk 24, 但只有 mipmap-*/ic_launcher.png (无 anydpi-v26)
- ic_launcher.png 与 ic_launcher_round.png MD5 完全相同, 圆形版只是方形副本
- API 26+ 用户在 OEM 圆形/水滴/方形启动器上图标会被硬切, 主体缺失
新增资源
- drawable/ic_launcher_background.xml: 矢量色块 #83D0F1 (原图四角采样 RGB 131,208,241)
- drawable/ic_launcher_foreground.xml: <mipmap> 引用密度分桶位图
- mipmap-anydpi-v26/ic_launcher.xml + ic_launcher_round.xml: adaptive-icon 定义
(含 <monochrome> 支持 Android 13+ 主题化图标)
- mipmap-{xhdpi,xxhdpi,xxxhdpi}/ic_launcher_foreground.webp:
从 app_icon_original.png (2048px) 中心裁 80% + cwebp -q 90 生成
体积比对应 ic_launcher.png 小 60-70% (xxhdpi: 7.4KB vs 22.5KB)
设计决策
- foreground 用位图而非矢量: 原图主体是写实风格, 矢量化会损失质量
- foreground 源图用 git 历史临时恢复生成, 不重新入库 (保持 Task 1 清理成果)
- 保留 mipmap-*/ic_launcher.png 作 API 24-25 回退 (不删)
- AndroidManifest.xml 无需改: @mipmap/ic_launcher 在 API 26+ 自动取 anydpi-v26
设备验证 (emulator API 37, Pixel Launcher)
- 安装 + 回桌面, hotseat 最右 YaYa 图标显示正常
- analyze_image 确认: 圆形遮罩下背景填满, 黄色主体居中无裁切
- 颜色与原设计一致 (主体 RGB~254,213,74, 背景 #83D0F1)
构建验证
- unzip -l 确认 APK 含 anydpi-v26/*.xml + drawable/ic_launcher_*.xml + 各密度 foreground.webp
- ./gradlew :app:assembleDebug → BUILD SUCCESSFUL
- APK 累计 -489KB (baseline 24,416,752 → 23,915,694, 主要是 Task 1 删 PNG)
This commit is contained in:
parent
58a97d1725
commit
ac41eef37b
11
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
11
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Adaptive Icon 背景: 纯色块, 取自原图四角采样 RGB(131,208,241) -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#83D0F1"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
</vector>
|
||||
7
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
7
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Adaptive Icon 前景: 引用 mipmap 中密度分桶的 foreground 位图,
|
||||
避免矢量化位图主体的质量损失。
|
||||
-->
|
||||
<mipmap xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:src="@mipmap/ic_launcher_foreground" />
|
||||
10
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
10
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Adaptive Icon (API 26+): 系统按 OEM 启动器形状自动裁切背景+前景。
|
||||
monochrome 让 Android 13+ 主题化图标生效。
|
||||
-->
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
7
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
7
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Adaptive Icon 圆形版 (API 26+), 内容与 ic_launcher.xml 一致 -->
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp
Normal file
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Loading…
x
Reference in New Issue
Block a user