簡體   English   中英

Oreo 上的應用啟動器圖標已更改為默認圖標

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

我創建了一個帶有自己的啟動器圖標的 Android 應用程序。 它適用於牛軋糖。 但是使用 Oreo,我的圖標被默認的 Android 圖標取代。 我已經在 mipmap 資源中為多個密度定義了ic_launcher.pngic_launcher_round.png

我的清單包含以下行:

android:roundIcon="@mipmap/ic_launcher_round"

我應該怎么做才能讓我自己的圖標出現在 Oreo 上?

對於 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 圖標,但它們不會按原樣顯示,並且通常會繪制在白色背景之上。

您可以在以下位置閱讀更多信息: 自適應圖標

最好的解決方案是刪除 mipmap-anydpi-v26 文件夾,然后應用程序將采用默認圖標。 在 android studio 項目模式下轉到這個包

res/mipmap-anydpi-v26

刪除它並重建和運行項目。

我的解決方案:檢查 res/mipmap-anydpi-v26 文件夾,然后您將看到 ic_launcher.xml 和 ic_launcher_round.xml 文件編輯這些 xml 文件以指向您要使用的實際 png 文件:

如果此類 png 文件在 drawable 文件夾中不可用,請添加它。

這就解決了問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM