在 Android Studio 3.0.1 中使用不带背景色或 xml 的 Image Asset 创建启动器图标

2024-04-26

您可能会认为这个问题是重复的this https://stackoverflow.com/questions/37085753/android-studio-image-asset-launcher-icon-background-color一。但从那时起,Android Studio 已经更新,并且给出的解决方案不再起作用。

为什么我们在创建图像资源时必须有背景?这背后的原因是什么?我们应该如何改变launcher_icon没有任何背景?我在图像资源中没有看到任何禁用背景的选项。

或者,我使用空背景,但这在全出血图层中不起作用:

<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
</vector>

或者,只需删除背景,但这会在您的内容中添加白色背景launcher_icon:

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Remove the background here and leave the foreground  -->
    <foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

Or, change icon type into Legacy Only and set shape to none: enter image description here

尽管如此,安装后启动器图标仍有白色背景。

那么,如何使用图像资源为我的启动器图标获得透明背景或无背景呢?


这不是您使用 Android Studio 创建的图标的问题,而是与您正在测试应用程序的特定设备相关的问题。 事实上,在图像资源中,如果将“形状”指定为“无”,则会获得透明背景。

要解决您的问题,请尝试使用不同的主页主题,例如;您可以在“设置”-“主页”中更改主页主题。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Android Studio 3.0.1 中使用不带背景色或 xml 的 Image Asset 创建启动器图标 的相关文章

随机推荐