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

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

问题描述

图标前景使用PNG图片,背景完全透明.

使用 Android Studio >新图像资产 >在 Asset Studio 中配置图像资产对话框,实际上已经尝试了非常多的背景选项组合,包括从路径中完全删除文件和删除 ic_launcher.xml 中的背景标签和ic_launcher_round.xml.

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

许多应用程序设法仅在其图标上有一个前景,所以这是可能的.我在这里做错了什么?

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

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

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

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.

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.

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.

Screen capture from device running API 25

解决方案

Method 1:

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>

Method 2:

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

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

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