【问题标题】:app launcher icon changed to default icon on Oreo应用启动器图标更改为奥利奥上的默认图标
【发布时间】:2018-12-22 12:58:15
【问题描述】:

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

我的清单包含以下行:

android:roundIcon="@mipmap/ic_launcher_round"

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

【问题讨论】:

    标签: android launcher android-8.0-oreo


    【解决方案1】:

    我的解决方案: 检查 res/mipmap-anydpi-v26 文件夹,然后你会看到 ic_launcher.xml 和 ic_launcher_round.xml 文件 编辑这些 xml 文件以指向您要使用的实际 png 文件:

    如果drawable文件夹中没有这样的png文件,添加它。

    这解决了问题。

    【讨论】:

      【解决方案2】:

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

      mipmap-anydpi-v26

      该文件夹(通常)包含两个 xml 文件 ic_launcheric_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 图标,但它们不会按原样显示,并且通常会绘制在白色背景之上。

      您可以阅读更多内容:Adaptive icons

      【讨论】:

      • 谢谢达莉亚。我没有注意到这个 mipmap-anydpi-v26 文件夹。我刚刚删除了它,现在它在 Oreo 上运行良好。稍后我会检查我能用这个“自适应图标”做些什么。
      • @VadimKotov 我添加了自适应图标的链接。 Android Studio 中的默认模板及其内容未记录在 AFAIK 中。
      【解决方案3】:

      最好的解决方案是删除 mipmap-anydpi-v26 文件夹,然后应用程序将采用默认图标。在 android studio Project 模式下进入这个包

      res/mipmap-anydpi-v26

      删除它并重建并运行项目。

      【讨论】:

        猜你喜欢
        • 2018-06-19
        • 2020-04-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多