How to change alpha color object?

Total Post:61

 1226  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"

  1. Post:29

    Re: How to change alpha color object?

    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)