Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

java - How to make the icon background of an Android app transparent?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...