Elaman Aitymbet
Elaman Aitymbet

Reputation: 515

Android Studio change transparency of Image Assets

When I create new "Image Asset" (Action Bar and Tab Icon) in Android Studio using my own icon as base, I get finally semi-transparent icons. (Android Studio change original color transparency). How to prevent it and save original colors?

This is image before download to Android studio (pure black)

enter image description here

This is after download to Android studio with image asset and I set white color. It has became transparent.

enter image description here

Upvotes: 23

Views: 26208

Answers (7)

instanceof
instanceof

Reputation: 1466

Thanks to @Gjchoza for this. The only thing that helped me create nice icons exactly how I needed them was this site.

Not even Android Studio 4.0's Image Asset Creation tool could provide for my needs.

Upvotes: 1

Gjchoza
Gjchoza

Reputation: 187

I did not find a way to configure the Image Asset (Action Bar and Tab Icon) so it would not generate semi-transparent icons.

However, if you select "Notification Icons" instead of "Action Bar and Tab Icons", the generated icon set is not semi-transparent (it is opaque). I'm currently using the generated icons for my Action Bars and Tabs.

Alternatively, I found the following website https://romannurik.github.io/AndroidAssetStudio/index.html which mimics the Image Asset Studio and generates opaque icon sets.

Upvotes: 2

Daniel Beltrami
Daniel Beltrami

Reputation: 776

For correct this unwanted alfa, I make sure that Android Studio create a XML for this drawable, than I edit it, like here "ic_cinema.xml":

ic_cinema.xml

So, now I remove or edit alfa parameter

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24"
    android:tint="#FFFFFF"
    android:alpha="0.8"> <!-- HERE YOU MAKE YOUR CHANGE -->
    <path
        android:fillColor="#FF000000"
        android:pathData="M18,4l2,4h-3l-2,-4h-2l2,4h-3l-2,-4H8l2,4H7L5,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V4h-4z"/>
</vector>

Upvotes: 2

suresh rajana
suresh rajana

Reputation: 23

Easy way to remove default background color in android studio 3.0

step 1: select new image assert in mipmap folder mipmap->new->image Assert

step 2: select foreground tab and load your icon image in file location path, adjust the image set according to your view the available option like (trim, resize)

step 3: then select background tab and delete the path from the path locator tab. step 4: go to ic_lancher.xml file under the mipmap folder, then delete

the line of code.

step 5: do the same operation on ic-launcher_round.xml file under mipmap folder

 <background  android :drawable="@mipmap/ic_lancher_round_background"/>

then you can find your icon without android studio default green cover background. step_1 step_2step_3 step_4

Upvotes: 2

Pavel Shorokhov
Pavel Shorokhov

Reputation: 4974

I have the same problem, and found solution in post-convertation via imagemagick.

convert ic_action.png -fuzz 50% -channel RGBA -fill white -opaque white ic_action.png

We select all semi-white color and replace to pure white. Also for black:

convert ic_action.png -fuzz 50% -channel RGBA -fill black -opaque black ic_action.png

It is result:

Before and after

And finally some tips and tricks, how to convert ic_action.png in one line in bash. Do it from project root.

Firstly find all files of icon:

find app/src -name "ic_action_name.png"

Next get it with xargs with name ICON:

xargs -iICON

And get command:

find app/src -name "ic_action_name.png" | xargs -iICON convert ICON -fuzz 50% -channel RGBA -fill white -opaque white ICON

Replace ic_action_name.png to your icon name, and if need white to black or other color (imagemagick also supports RGB syntax '#FF0000').

Upvotes: 6

Vishal Kumar
Vishal Kumar

Reputation: 4617

I also did this silly mistake...while adding an Image Asset.... Please notice the Shape option in the drop down. Select None so that the image will appear transparent in Android Studio.

Find Android Studio Screen

Upvotes: 15

Aspicas
Aspicas

Reputation: 4497

You can unchecked this icon to see the background color...

one

Upvotes: 2

Related Questions