How to make any html color code semi transparent [Android]
Asked Answered
E

4

8

I have one Android application were i have one shape and in that i have one solid tag.

I want to make this shape 20% transparent with above color code.
How should i do that?

Employ answered 9/7, 2013 at 7:48 Comment(2)
possible duplicate.#11286461Valiancy
I think you are using Android Color code- Color.Red etc? So please use color code for that like-#452558 and in your circle use other color code which one is lighter than etc.. OR use setAlpha(200);Rosalbarosalee
C
24

If the color is represented in hexadecimal, like #424242, then adding two more digits in front of this "number" will represent the transparency, ex: #66424242. (66 in this example)
You can play a bit until arrive at desired effect.

Contribute answered 9/7, 2013 at 7:53 Comment(2)
so this AA ranges from 0 to 255 also 66 is how many % of 100?Employ
Well, you could convert the hexa digits to decimal, and then do a simple math to know what percentage of transparency represent that alfa value. In this case, 66 would represent about 40%.Contribute
G
3

android:color="#66FF0000" is partially transparent red and if you decreasing the value of 6 as 5,4,3 up to 1 as "#56FF0000" ,"#46FF0000","#36FF0000","#26FF0000", the transparent color will becoming thin and the same way if u increase the first number as "#76FF0000","#86FF0000", like that the transparent color becoming thick.so we can arrange the transparency of color ourself. and it is applicable to all type of colors!!

Gayn answered 4/6, 2014 at 19:30 Comment(0)
N
2

Would something like this work?

android:color="#66FF0000"    // Partially transparent red

Taken from https://mcmap.net/q/116192/-how-to-set-opacity-alpha-for-view-in-android

Neelon answered 9/7, 2013 at 7:53 Comment(0)
E
2

I have tried adding two digits to the front of the 'number' e.g. #66424242, this definitely works since I use it on my blog

Epinephrine answered 16/10, 2017 at 18:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.