22

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

Elaman Aitymbet
  • 505
  • 1
  • 6
  • 21
  • A solution to consider: https://stackoverflow.com/a/62150079/7210237 Similar to the response from @Gjchoza, but uses another official online tool. – Jenea Vranceanu Jun 02 '20 at 10:38

7 Answers7

15

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

Vishal Kumar
  • 3,811
  • 1
  • 21
  • 30
  • 1
    I didn't realize the area beneath `Icon Type` input is scrollable, and that there are other options there (including color!). Thanks - nice pointer – Gene Bo May 30 '17 at 20:37
6

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').

Pavel Shorokhov
  • 2,922
  • 1
  • 23
  • 33
2

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

one

Aspicas
  • 4,403
  • 4
  • 28
  • 51
  • thank's for attention. Yeh right, but it's really change transparent of icon. I update my question and add new image and description. you can see also my question this http://stackoverflow.com/questions/36882124/android-tab-icon-color-is-not-clear?noredirect=1#comment61335815_36882124 – Elaman Aitymbet Apr 27 '16 at 11:17
  • @ElamanAitymbet well... do you need the icon with background or not? I'm really don't understand what do you need it. – Aspicas Apr 27 '16 at 11:21
  • I only want to change image color from black to white with Image Asset.Only! But when I use it in tablayout icon I found that icon color transparent – Elaman Aitymbet Apr 27 '16 at 11:31
  • @ElamanAitymbet Why don't change the icon background with another program like `photoshop` or similar and import on project with background color? or... you can put the icon inside a `LinearLayour` (or another) and put a `background Color` to the `layout` in background – Aspicas Apr 27 '16 at 11:38
2

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

Rahul Devanavar
  • 3,188
  • 2
  • 21
  • 50
2

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.

Gjchoza
  • 177
  • 1
  • 7
1

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>
Daniel Beltrami
  • 571
  • 6
  • 16
0

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.

instanceof
  • 977
  • 17
  • 28