ic_launcher.xml 未被用作应用程序图标

ic_launcher.xml not being used as app icon

我正在开发 Android 应用。

我正在尝试使用 ic_launcher.xml 和 ic_launcher_round.xml 作为应用程序图标,因为我认为这是正确的方法吗?

无论如何,我有一张png图片,108x108px,32位颜色。我在 ic_launcher 和 ic_launcher_round 中都使用它作为:

<?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/app_icon" />
</adaptive-icon>

两个 xml 文件的代码相同。

问题是在较新的 os 版本(8.0+,圆形图标)上它运行良好,但在早期版本(7.0,方形图标)上它根本不起作用,并默认为标准 android 图标。

我目前正在创建我将用于替换 mipmap 中的 ic_launcher.png 的所有图像,但除此之外我还能做其他事情吗?

在清单中,我将它们用作:

android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"

您可以使用 Android Studio 工具自定义应用的图标。

  1. 在项目 window 中,select Android 视图。
  2. 右键单击 res 文件夹,然后 select 新建 > 图像资源。

更多:https://developer.android.com/studio/write/image-asset-studio

我建议您至少使用 512x512 像素的图像来为应用程序生成启动器图标。

有很棒的在线工具可以生成适合所有屏幕的启动器图标:

http://romannurik.github.io/AndroidAssetStudio/icons-launcher.html

或者您可以使用 Android Studio 的默认工具来导入您的图像并生成它。

(右击)->新建->图像资源