mipmap/ic_launcher.png 仍需要 SDK >=26?

mipmap/ic_launcher.png still required for SDK >=26?

在 Android 中有两种指定启动器图标(可以说是应用程序图标)的方法:

'old' 方式

在通常命名为 ic_launcher.png 的 mipmap 文件夹中指定不同的 png 文件,但可以通过 android:icon="@mipmap/appicon_android"

设置名称

自适应图标

参考https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive。 这里的图标由前面和背景的 drawables 组成(完整的描述参见上面提到的 link)。 Android 说:

Next you must create alternative drawable resources in your app for use with Android 8.0 (API level 26) in res/mipmap-anydpi-v26/ic_launcher.xml. You can then use the element to define the foreground and background layer drawables for your icons.

<?xml version="1.0" encoding="utf-8"?>
<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>

如果我的应用有:

minSdkVersion 26
targetSdkVersion 29

是否仍应包含 'old' 方式的 png 文件,还是仅显示自适应图标就足够了?

is it enough only to have the adaptive icons present?

是的。

您必须只考虑您的最低 SDK 版本。如果您的最低 SDK 版本高于 API 21,您可以自由使用矢量绘图而不是 PNG。

其他来源: