Android Studio change transparency of Image Assets
Asked Answered
W

7

23

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

Whiten answered 27/4, 2016 at 11:5 Comment(1)
A solution to consider: https://mcmap.net/q/585774/-android-toolbar-icon-color-not-so-bright Similar to the response from @Gjchoza, but uses another official online tool.Larose
I
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

Ictus answered 5/12, 2016 at 11:9 Comment(1)
I didn't realize the area beneath Icon Type input is scrollable, and that there are other options there (including color!). Thanks - nice pointerAronarondel
B
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').

Basham answered 9/3, 2017 at 21:6 Comment(1)
For mac os xargs's, use xargs -IICON (big "I" instead of small "i") :Loehr
M
2

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

one

Merrilee answered 27/4, 2016 at 11:9 Comment(4)
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 #36882624Whiten
@ElamanAitymbet well... do you need the icon with background or not? I'm really don't understand what do you need it.Merrilee
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 transparentWhiten
@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 backgroundMerrilee
L
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

Ligurian answered 14/11, 2017 at 5:59 Comment(0)
S
2

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>
Snood answered 30/8, 2019 at 14:37 Comment(0)
F
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.

Furey answered 20/11, 2019 at 18:46 Comment(0)
I
1

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.

Inflammatory answered 21/7, 2020 at 8:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.