我们正在实现一个圆形图标(带有前景和背景)和图标。
<application
android:allowBackup="false"
tools:replace="android:allowBackup"
android:label="@string/app_name"
android:supportsRtl="true"
android:icon="@mipmap/logo" //normal logo
android:roundIcon="@mipmap/logo_o" //Our logo with foreground and background
android:name=".MyApplication"/>
适用于每个版本,但不适用于 API 25
我们的前景和背景代码是下一个
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/logo_background"/>
<foreground android:drawable="@mipmap/logo_foreground"/>
</adaptive-icon>
Reason:
Android 在 Android 8.0(API 级别 26)及更高版本上支持自适应图标。欲了解更多信息,请检查以下内容文档。您似乎没有为 API 级别 25 及以下的设备提供后备图像。
怎么解决:
仅在 API 26 及更高版本上使用自适应图标,并为旧设备提供应用程序图标的 png 图像。
您的文件夹结构应该是:
+-- _mipmap-anydpi-v26
| +-- ic_launcher_round.xml
| +-- ic_launcher.xml
+-- mipmap-mdpi
| +-- ic_launcher_round.png
| +-- ic_launcher.png
+-- mipmap-hdpi
| +-- ic_launcher_round.png
| +-- ic_launcher.png
+-- mipmap-xhdpi
| +-- ic_launcher_round.png
| +-- ic_launcher.png
+-- mipmap-xxhdpi
| +-- ic_launcher_round.png
| +-- ic_launcher.png
+-- mipmap-xxxhdpi
| +-- ic_launcher_round.png
| +-- ic_launcher.png
并将它们在清单中配置为:
<application
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
相同的内容可用于ic_launcher_round.xml
and 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" />
</adaptive-icon>
png 图像ic_launcher_round.png
and ic_launcher.png
应在单个 png 中包含前景层和背景层,并根据应用程序图标的默认版本和圆形版本进行形状调整。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)