Android - How to set color value for TRANSPARENT

how to get parseColor color value for transparency.

mPaint.setColor(Color.parseColor("#FFFF00")); 

thanks for the help

+6
source share
3 answers

Suppose your preferred color is red #FF0000

Adding 00 at the beginning will make it 100% transparent, and adding FF will make it 100% hard.

So, 100% transparent color: #00ff0000 and 100% solid color: #ffff0000

And any value in the range from 00 to ff can be used to adjust the transparency.

+15
source

just used android color string

 mPaint.setColor(getResources().getColor(android.R.color.transparent)); 
+4
source

You can use Color.argb (int alpha, int red, int green, int blue)

Alpha is transparent. 0 for completely transparent. 255 for opaque.

http://developer.android.com/reference/android/graphics/Color.html#argb(int,%20int,%20int,%20int)

Returns int-color from alpha, red, green, blue components. These component values ​​must be [0..255], but the range check is not performed, therefore, if they are outside the valid range, the returned color is undefined.

0
source

All Articles