简体   繁体   English

Oreo 上的应用启动器图标已更改为默认图标

[英]app launcher icon changed to default icon on Oreo

I have created an Android app with its own launcher icon.我创建了一个带有自己的启动器图标的 Android 应用程序。 It worked well with Nougat.它适用于牛轧糖。 But with Oreo, my icon is replaced by the default Android icon.但是使用 Oreo,我的图标被默认的 Android 图标取代。 I have defined ic_launcher.png and ic_launcher_round.png in the mipmap resources for several densities.我已经在 mipmap 资源中为多个密度定义了ic_launcher.pngic_launcher_round.png

My manifest contains the following line:我的清单包含以下行:

android:roundIcon="@mipmap/ic_launcher_round"

What should I do to make my own icon appear on Oreo ?我应该怎么做才能让我自己的图标出现在 Oreo 上?

For API 26+ default Android application template defines another icon resource folder对于 API 26+ 默认的 Android 应用程序模板定义了另一个图标资源文件夹

mipmap-anydpi-v26

That folder (usually) contains two xml files ic_launcher and ic_launcher_round that match icon resources declared in manifest for API 26+该文件夹(通常)包含两个xml文件ic_launcheric_launcher_round ,它们匹配 API 26+ 清单中声明的​​图标资源

Content of those files looks like following:这些文件的内容如下所示:

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

In order to have your icon you also need to change all drawables (in all density buckets) listed there - namely ic_launcher_background and ic_launcher_foreground为了拥有您的图标,您还需要更改那里列出的所有可绘制对象(在所有密度桶中) - 即ic_launcher_backgroundic_launcher_foreground

Or you can just delete that folder, in which case android will fallback to using your png icons, but they will not appear as-is and will be commonly drawn on top of white background.或者您可以删除该文件夹,在这种情况下,android 将回退到使用您的 png 图标,但它们不会按原样显示,并且通常会绘制在白色背景之上。

You can read more at: Adaptive icons您可以在以下位置阅读更多信息: 自适应图标

Best solution is delete mipmap-anydpi-v26 folder then app will take default icon.最好的解决方案是删除 mipmap-anydpi-v26 文件夹,然后应用程序将采用默认图标。 In android studio Project mode go to this package在 android studio 项目模式下转到这个包

res/mipmap-anydpi-v26 res/mipmap-anydpi-v26

delete it and rebuild and Run Project.删除它并重建和运行项目。

My solution: check res/mipmap-anydpi-v26 folder, then you will see ic_launcher.xml and ic_launcher_round.xml files edit these xml files to point to the actual png file you want to use:我的解决方案:检查 res/mipmap-anydpi-v26 文件夹,然后您将看到 ic_launcher.xml 和 ic_launcher_round.xml 文件编辑这些 xml 文件以指向您要使用的实际 png 文件:

If such png file is not available inside the drawable folder, add it.如果此类 png 文件在 drawable 文件夹中不可用,请添加它。

That solves the issue.这就解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM