【问题标题】:app icon has white circle around it for android on phonegap/cordova应用程序图标周围有白色圆圈,适用于 phonegap/cordova 上的 android
【发布时间】:2018-07-31 05:08:15
【问题描述】:

我更新了 phonegap,现在 Android 图标周围有一个白色圆圈,就像我手机上 1/2 的图标一样。我不想要白色圆圈。

附件显示的是正常的 Arlo 图标,然后是另外两个带有白色圆圈的图标。我的 config.xml 中列出的图标不是这样的 png。

我怎样才能再次获得没有圆圈的图标,例如 Arlo 图标?

<platform name="android">
    <!--
        ldpi    : 36x36 px
        mdpi    : 48x48 px
        hdpi    : 72x72 px
        xhdpi   : 96x96 px
        xxhdpi  : 144x144 px
        xxxhdpi : 192x192 px
    -->
    <icon src="res/android/ldpi.png" density="ldpi" />
    <icon src="res/android/mdpi.png" density="mdpi" />
    <icon src="res/android/hdpi.png" density="hdpi" />
    <icon src="res/android/xhdpi.png" density="xhdpi" />
    <icon src="res/android/xxhdpi.png" density="xxhdpi" />
    <icon src="res/android/xxxhdpi.png" density="xxxhdpi" />
</platform>

【问题讨论】:

  • 检查this示例
  • 如果您找到解决方案,请更新。我遇到了同样的问题,只是在最近的版本中弹出。我的猜测是它与 Android 更新有关,因为我没有更改任何图标资源或重新生成(我使用的是 ionic 3)
  • 安德鲁,我现在发布了一个答案。希望对您有所帮助

标签: android cordova phonegap


【解决方案1】:

我确实修复了它,但老实说我记不起我所做的一切。这是我肯定记得的。

1)我更新到了cordova 8.0.0(不确定是否需要)

2) 从 config.xml 中删除了所有 android 图标配置,除了我离开了:

<icon src="icon.png" />

3) 使用 Android Studio 生成自适应图标(非常简单):https://developer.android.com/studio/write/image-asset-studio#create-adaptive

每次使用 phonegap prepare android(或 cordova prepare android)时,必须执行以下步骤,当然如果您 rm/add 平台。 p>

4) 将生成的drawable/values文件夹/文件从Android Studio复制到approot/platforms/android/app/src/main/res

5) 仔细检查 approot/platforms/android/app/src/AndroidManifest.xml 有这一段:

<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">

可能有更好的方法,但我的应用正在使用自适应图标,我很高兴。希望这会有所帮助。抱歉,我记不住所有细节!

【讨论】:

  • 这让我找到了正确的答案,谢谢!我在下面发布了我的解决方案,一个不需要处理平台目录的解决方案。
【解决方案2】:

Zomg,太晚了,但我花了 2 个小时才弄清楚这一点并想分享!

我使用 Android Studio 创建图标,从一个新的空白项目开始。我能够从here 的描述中弄清楚如何使用图标生成器,虽然我觉得我很幸运找到了它,所以如果你需要它,你可以支付 40 美元观看视频以查看该界面在哪里是。然后,我将从该项目中的 /app/src/main/res 文件夹生成的文件复制到我的 /res/icons/android 目录中。

然后,我将它添加到 config.xml(我在这个块中也有其他东西,但这是相关的东西:

<platform name="android">
    <!-- Depend on v21 of appcompat-v7 support library -->
    <framework src="com.android.support:appcompat-v7:21+" />
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" />
    </edit-config>
    <resource-file src="res/icons/android/drawable/ic_launcher_background.xml" target="app/src/main/res/drawable/ic_launcher_background.xml" />
    <resource-file src="res/icons/android/drawable-v24/ic_launcher_foreground.xml" target="app/src/main/res/drawable-v24/ic_launcher_foreground.xml" />
    <resource-file src="res/icons/android/mipmap-anydpi-v26/ic_launcher_round.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" />
    <resource-file src="res/icons/android/mipmap-anydpi-v26/ic_launcher.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" />
    <resource-file src="res/icons/android/mipmap-hdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png" />
    <resource-file src="res/icons/android/mipmap-hdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-hdpi/ic_launcher_round.png" />
    <resource-file src="res/icons/android/mipmap-hdpi/ic_launcher.png" target="app/src/main/res/mipmap-hdpi/ic_launcher.png" />
    <resource-file src="res/icons/android/mipmap-mdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png" />
    <resource-file src="res/icons/android/mipmap-mdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-mdpi/ic_launcher_round.png" />
    <resource-file src="res/icons/android/mipmap-mdpi/ic_launcher.png" target="app/src/main/res/mipmap-mdpi/ic_launcher.png" />
    <resource-file src="res/icons/android/mipmap-xhdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png" />
    <resource-file src="res/icons/android/mipmap-xhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xhdpi/ic_launcher_round.png" />
    <resource-file src="res/icons/android/mipmap-xhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xhdpi/ic_launcher.png" />
    <resource-file src="res/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png" />
    <resource-file src="res/icons/android/mipmap-xxhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png" />
    <resource-file src="res/icons/android/mipmap-xxhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xxhdpi/ic_launcher.png" />
    <resource-file src="res/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png" />
    <resource-file src="res/icons/android/mipmap-xxxhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png" />
    <resource-file src="res/icons/android/mipmap-xxxhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher.png" />
 </platform>

我不确定是否需要 appcompat 行,因此如果您愿意,可以尝试不使用它。我确实还需要在每次进行更改时删除 android 平台并重新添加,以使其注意到更改。在某一时刻,我还删除了文件夹 .idea/caches 以清除缓存。所有这一切,现在它的工作原理!我认为这是一个比这里接受的答案更好的解决方案,因为您不会使用平台文件夹,因此不需要每次都手动复制内容,一次完成。希望这可以节省一些时间!

【讨论】:

  • 对于 Ionic 4 使用:&lt;resource-file src="resources/android/d... 所有标签中的此路径。
【解决方案3】:

看起来应用程序从 config.xml 文件中获取了 ldpi 的第一个图标

尝试添加

<icon src="www/res/android/ldpi.png" /> 

没有密度,在配置文件中的平台标记之外,大小为 1024x1024,因此它将使用应用程序图标的全部空间。

【讨论】:

    猜你喜欢
    • 2020-02-22
    • 1970-01-01
    • 2017-03-17
    • 1970-01-01
    • 2013-07-11
    • 2022-10-15
    • 1970-01-01
    • 1970-01-01
    • 2018-07-03
    相关资源
    最近更新 更多