Color Manipulation
suggest changeChange a color by reading its alpha, red, green, and blue channels, then writing them back.
Extract the RGB channels. Color.parseColor accepts a #RRGGBB or #AARRGGBB string. There is no Color.parse.
int yourColor = Color.parseColor("#ae1f67");
int red = Color.red(yourColor);
int green = Color.green(yourColor);
int blue = Color.blue(yourColor);
Adjust the channels, then pack them into a color. Each channel must be in the range 0–255. Color.rgb and Color.argb throw IllegalArgumentException outside that range.
int newColor = Color.rgb(red, green, blue);
To set opacity as well, pass an alpha from 0 (transparent) through 255 (opaque):
int newColor = Color.argb(alpha, red, green, blue);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents