android - 应用程序图标仅在 API21 中显示,但在其他 api 中失败
问题描述
我的清单文件中有此代码。我面临的问题是该图标仅显示在 Android Lollipop (Api21,Asus Nexus Tab)中。我已经在 Oreo (Oppo A3S) 和 Android P (Samsung Galaxy S10+) 中进行了测试,但没有显示图标。mipmap 中的图像看起来不错。
<application
android:name=".Application"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
仅显示纯色(图标的背景)。这与mipmap中的图像有关吗?因为它们看起来不错。即使清单中行号附近的图标预览看起来也不错。
我还观察到我只有一个 webp 文件,mipmap-anydpi-v26
但其他应用程序有 2 个 XML 文件,一个用于圆形文件,一个用于普通文件。
解决方案
您应该以正确的方式添加启动器图标。首先从 mipmap 中删除所有 ic_launcher 及其所有版本。现在创建图标类型为启动器图标(仅限旧版)或(自适应和旧版)的新图像资产。然后将其命名为 ic_launcher 并选择您的图像路径并设置填充、颜色等,然后下一步并完成。它会自动将资产作为清单中的启动器图标。如果不手动设置。
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
推荐阅读
- javascript - 在 AFrame 中使用按钮移动动态对象
- python - QTableView 的 HTML 渲染器 - 字体大小发生了什么变化?
- javascript - 在使用引导树视图填充之前对树数据进行排序
- postgresql - PostgreSQL 从时间戳中提取年份然后应用间隔计算
- r - 从满足其他列条件的上一行复制列的值
- javascript - 更新 .map 后的状态
- python - 使用 python 脚本将文本传递到 Windows cmd 行
- java - 不知道为什么我的 for 循环没有按照我的预期工作
- react-native - 功能组件调用其他功能导致无效的挂钩调用
- amazon-web-services - Rds_instance 无法使用 Ansible 在 Aurora 集群中创建 RDS 数据库