Home > DeveloperSection > Forums > How to change alpha color object?
Brad Pitt
Brad Pitt

Total Post:61

Posted on    November-07-2014 1:32 AM

 Android Java 

 1 Reply(s)
 786  View(s)
Rate this:
Is there a way to add aplha to color that i can get from a color string. Because now i can draw my color without the alpha by using the following code

CircleOptions options = new CircleOptions().center(new LatLng(car.getLatitude(), car.getLongitude()))


.strokeColor(Color.argb(50, 232, 245, 248))



This works fine. But i want to make the color more transparent. Is there a good way to add alpha do this color because i can only get out a "ColorString"

Maria Susan

Total Post:29

Posted on    November-07-2014 3:11 AM

Color is represented as a int and you can represent it with hex notation like 0xAARRGGBB, which means Alpha, Red, Green, Blue. So each value can be 0 to 255.

Thus, what you want can be achieved with some bit operations.

If you want reset alpha value then,

int newColor = 0x10000000 | (Color.parseColor(car.getColorString()) & 0xFFFFFF);
(0x10000000 means new alpha value - 16 which is about 6.274% alpha because 100% is 255)
(0xFFFFFF means we take only rgb value from a color)

Don't want to miss updates? Please click the below button!

Follow MindStick