To darken the color, you just need to remove the same amount from the red green and blue components.
Change Since you get the color from the hexadecimal value, you need to separate the components from it, reduce its value and return it back.
0xaarrggbb → a = alpha r = red g = green b = blue
int color = 0xff445566; // Get the color component: int alpha |= a << 24; int red |= r << 16; int green |= g << 8; int blue |= b; int newalpha = alpha; int newred = red - proportional amount ; int newgreen = green - proportional amount ; int newblue = blue - proportional amount ; // Set the color component color = (color & ~(0xFF << 24)) | (newalpha << 24); color = (color & ~(0xFF << 16)) | (newred << 16); color = (color & ~(0xFF << 8)) | (newgreen << 8); color = (color & ~0xFF) | newblue;
source share