不久前,我制作了一个简单的Android应用程序-一个上传数据的共享意图处理程序。
现在我为它设计了一个新的SVG图标,在项目中导入为矢量图形,然后使用InkScape转换为一系列PNG并替换项目中的所有PNG。
应用程序现在显示在新图标上
但是Android11(API30级,三星银河A50,股票固件)仍然显示旧图标。
有没有更多的地方留在应用程序中的默认图标(绿色android头耳朵)可以居住!
可能是默认图标显示时,一些预期的资源只是缺少?
我用以下文件中的新图像替换了图像:
我注意到在app\src\main\res\抽屉\
文件夹中没有ic_launcher_foreground. xml
,只有在app\src\main\res\抽屉-v24\
中,这正常吗?
我的app\src\main\res\mipmap-anydpi-v26\ic_launcher. xml
文件如下所示:
<?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>
当我在Android Studio中按Ctrl键单击@Drawable/ic_launcher_foreground
时,它会将我引导到app\src\main\res\Drawable-v24\ic_launcher_foreground. xml
。
您应该尝试添加图标
资源-
在那里更改您的启动器图标,它应该可以正确地在任何地方看到。
尝试更改您的ic_launcher. xml
文件
<?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>
到
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
自适应图标仅用于Android 8(SDK26)及更高版本,因此运行Android 11的设备会引用此文件,而运行旧版本Android的设备则不会。