如何让Android应用的图标背景透明? [英] How to make the icon background of an Android app transparent?

查看:1352
本文介绍了如何让Android应用的图标背景透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PNG图像用作图标前景,背景应完全透明。

A PNG image is to be used as the icon foreground, and the background should be completely transparent.

使用 Android Studio>新图像资产>在Asset Studio中配置图像资源对话框,几乎已经尝试了背景选项的组合,包括完全从路径中删除文件并删除 ic_launcher中的背景标记。 xml ic_launcher_round.xml

Using Android Studio > New Image Asset > Configure Image Asset dialog in the Asset Studio, virtually very combination of options for the background has been tried, including removing the file entirely from the path and deleting the background tags in ic_launcher.xml and ic_launcher_round.xml.

从此向导中的路径中删除文件从XML文件中删除标签几乎可以解决问题,但是仍然有一个微弱的黑色轮廓作为背景(~alpha = 20%)。当查看设备启动器上的图标时,背景图层的所有其他选项在前景图像后面留下鲜明的白色或黑色背景。

Removing the file from the path in this wizard and removing the tags from the XML files almost does the trick, but a faint black outline remains as the background (~alpha=20%). All other options for the Background Layer leave either a stark white or black background behind the foreground image when viewing the icon on the device's launcher.

许多应用程序设法有前景只有他们的图标,所以它是可能的。我在这里做错了什么?

Many apps manage to have a foreground only on their icons, so it is possible. What am I doing wrong here?

更新:感谢您的快速评论!我尝试了两种解决方案作为答案,同样的结果。屏幕截图按照建议上传。

Update: Thank you for the quick comments! I tried both the solutions provided as answers, same result. Screen capture is uploaded as suggested.

只更新向导中的Legacy图标是不够的,因为这只会更改Legacy图标格式。还需要较新的自适应图标。即使背景设置为完全透明的方形png,Android Studio也会将其更改为白色。如果完全删除后台文件,则向导允许完成,但Android Studio使用稍微不透明的黑色背景,如图所示。关于上传的图像,前景后面应该没有任何内容,完全灰色,在这种情况下没有任何可见的圆圈。

Updating just the Legacy icon in the wizard is not sufficient, as that only changes the Legacy icon format. The newer "Adaptive" icons are required as well. Even if the background is set to a completely transparent square png, Android Studio changes it to white. If the background file is removed entirely, the wizard allows completion, but then Android Studio uses a slightly opaque black background, as shown. With respect to the uploaded image, there should be nothing behind the foreground, completely gray to in this case without any visible circle.

运行API 25的设备的屏幕截图

推荐答案

方法1:

如果您有png,只需将其复制并粘贴到drawable中,然后参考图像名称来自清单。

if you have a png, just copy it and paste it in drawable, and refer to image name from manifest.

<application
        android:allowBackup="true"
        android:icon="@mipmap/new_image"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/new_image"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        ....
        </application>

方法2:

转到文件>新建>图片资源,确保选择png图像(透明背景)&将背景形状设置为无。

Goto file > new > image asset, make sure you select a png image (with transparent background) & set background shape to none.

< img src =https://i.stack.imgur.com/VkvLJ.jpgalt =在此输入图像说明>

这篇关于如何让Android应用的图标背景透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆