1

我的清单文件中有此代码。我面临的问题是该图标仅显示在 Android Lollipop (Api21,Asus Nexus Tab)中。我已经在 Oreo (Oppo A3S) 和 Android P (Samsung Galaxy S10+) 中进行了测试,但没有显示图标。mipmap 中的图像看起来不错。

 <application
        android:name=".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"
        tools:ignore="GoogleAppIndexingWarning">

仅显示纯色(图标的背景)。这与mipmap中的图像有关吗?因为它们看起来不错。即使清单中行号附近的图标预览看起来也不错。

我还观察到我只有一个 webp 文件,mipmap-anydpi-v26但其他应用程序有 2 个 XML 文件,一个用于圆形文件,一个用于普通文件。

4

2 回答 2

1

您应该以正确的方式添加启动器图标。首先从 mipmap 中删除所有 ic_launcher 及其所有版本。现在创建图标类型为启动器图标(仅限旧版)或(自适应和旧版)的新图像资产。然后将其命名为 ic_launcher 并选择您的图像路径并设置填充、颜色等,然后​​下一步并完成。它会自动将资产作为清单中的启动器图标。如果不手动设置。

android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
于 2020-07-21T19:04:56.380 回答
0

显然,这是因为 mipmap-anydpi-v26 中缺少 XML 文件。我在drawable中有两个XML文件。

在其他项目中查找了类似的文件,发现这两个 XML 文件基本上都包含标签,后面跟着背景和前景标签。

这两个标签的属性基本上是指drawable文件夹中的文件。最有可能的背景是一个布局资源文件,其中包含代表图标背景颜色的标签,前景是一个矢量。

但是删除所有 mipmap 并根据https://developer.android.com/studio/write/image-asset-studio#create-notification重新生成它们也应该有效。

于 2020-07-21T20:08:06.840 回答