Android Colors Color Manipulation

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

To manipulate colors we will modify the argb (Alpha, Red, Green and Blue) values of a color.

First extract RGB values from your color.

int yourColor = Color.parse("#ae1f67");

int red = Color.red(yourColor);
int green = Color.green(yourColor);
int blue = Color.blue(yourColor);

Now you can reduce or increase red, green, and blue values and combine them to be a color again:

 int newColor = Color.rgb(red, green, blue);

Or if you want to add some alpha to it, you can add it while creating the color:

 int newColor = Color.argb(alpha, red, green, blue);

Alpha and RGB values should be in the range [0-225].



Got any Android Question?