'Android - How to set color value to TRANSPARENT
how to get parseColor color value to transparent.
mPaint.setColor(Color.parseColor("#FFFF00"));
thanks for help
Solution 1:[1]
Suppose your preferred color is red #FF0000
Adding 00 in the beginning will make it 100% transparent and adding FF will make it 100% solid.
So, 100% transparent color is: #00ff0000
and 100% solid color is: #ffff0000
And any value in between 00 to ff can be used to adjust the transparency.
Solution 2:[2]
just used android color string
mPaint.setColor(getResources().getColor(android.R.color.transparent));
Solution 3:[3]
You can use Color.TRANSPARENT if you do not want to change the transparency level.
import android.graphics.Color;
// use Color.TRANSPARENT
mPaint.setColor(Color.TRANSPARENT);
https://developer.android.com/reference/android/graphics/Color#TRANSPARENT
Solution 4:[4]
You can use Color.argb(int alpha, int red, int green, int blue)
Alpha corresponds to transparency. 0 for fully transparent. 255 for opaque.
http://developer.android.com/reference/android/graphics/Color.html#argb(int,%20int,%20int,%20int)
Return a color-int from alpha, red, green, blue components. These component values should be [0..255], but there is no range check performed, so if they are out of range, the returned color is undefined.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | iphondroid |
| Solution 2 | Angad Tiwari |
| Solution 3 | |
| Solution 4 |
