Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 811
Elaman Aitymbet Avatar asked Apr 27 '16 11:04

Elaman Aitymbet


6 Answers

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

like image 198
Vishal Kumar Avatar answered Sep 28 '22 02:09

Vishal Kumar


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

like image 41
Pavel Shorokhov Avatar answered Sep 26 '22 02:09

Pavel Shorokhov


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

one

like image 28
Aspicas Avatar answered Sep 25 '22 02:09

Aspicas


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

like image 31
suresh rajana Avatar answered Sep 29 '22 02:09

suresh rajana


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>
like image 39
Daniel Beltrami Avatar answered Sep 25 '22 02:09

Daniel Beltrami


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.

like image 45
Gjchoza Avatar answered Sep 26 '22 02:09

Gjchoza