首页 > 解决方案 > 应用启动器图标更改为奥利奥上的默认图标

问题描述

我创建了一个带有自己的启动器图标的 Android 应用程序。它与牛轧糖配合得很好。但是使用 Oreo,我的图标被默认的 Android 图标取代。我已经在 mipmap 资源中定义ic_launcher.pngic_launcher_round.png几种密度。

我的清单包含以下行:

android:roundIcon="@mipmap/ic_launcher_round"

我应该怎么做才能让我自己的图标出现在 Oreo 上?

标签: androidlauncherandroid-8.0-oreo

解决方案


对于 API 26+ 默认 Android 应用程序模板定义了另一个图标资源文件夹

mipmap-anydpi-v26

该文件夹(通常)包含两个xml文件ic_launcher,并且ic_launcher_round与 API 26+ 清单中声明的​​图标资源相匹配

这些文件的内容如下所示:

<?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>

为了拥有您的图标,您还需要更改那里列出的所有可绘制对象(在所有密度桶中) - 即ic_launcher_backgroundic_launcher_foreground

或者您可以删除该文件夹,在这种情况下,android 将回退到使用您的 png 图标,但它们不会按原样显示,并且通常会绘制在白色背景之上。

您可以在以下位置阅读更多信息:自适应图标


推荐阅读