本文介绍了在Android Studio 3.0.1中使用不带背景色或xml的图像资产创建启动器图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可能会认为这个问题是 this 一个.但是从那以后,Android Studio进行了更新,给出的解决方案不再起作用.

You might be thinking this question is a duplicate of this one. But since then, Android Studio has been updated and the solution given there is not working anymore.

为什么在创建图像资产时被迫具有背景?这背后的原因是什么?我们应该如何在没有任何背景的情况下更改launcher_icon?我看不到任何禁用图像资产背景的选项.

Why are we forced to have a background when creating an Image Asset? What's the reason behind this? How we are supposed to change the launcher_icon without having any background? I don't see any option to disable the background in Image Asset.

或者,我使用一个空的背景,但是在全出血层中不起作用:

Alternatively, I use an empty background but this doesn't work in Full Bleed Layers:

<?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中添加白色背景:

Or, just remove the background, but this will add a white background in your 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>

或者,将icon type更改为Legacy Only并将shape设置为none:

Or, change icon type into Legacy Only and set shape to none:

仍然,启动器图标在安装后仍为白色背景.

Still, there's a white background in the launcher icon when installed.

那么,如何使用图像资产"为我的启动器图标获得透明背景,或者没有透明背景?

So how can I get a transparent background or none for that matter, for my Launcher icon using Image Asset?

推荐答案

这不是您使用Android Studio创建的图标的问题,而是与您要在其上测试应用程序的特定设备有关的问题.实际上,在图像资产"中,如果将形状"指定为无",则会得到透明背景.

It is not a problem of the icon you created with Android Studio, but it's a problem related to your specific device you're testing the application on.In fact, in the Image Asset if you specify the Shape to None, you get a trasparent background.

要解决您的问题,请尝试使用其他首页主题,例如 Nova启动器;您可以在设置"主页"中更改主页主题.

To address your problem, please try to use a different Home theme, like the Nova Launcher; you can change the home theme in Settings - Home.

这篇关于在Android Studio 3.0.1中使用不带背景色或xml的图像资产创建启动器图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 17:43