Skip to content

Instantly share code, notes, and snippets.

@kamilZ
Last active January 3, 2016 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamilZ/8518939 to your computer and use it in GitHub Desktop.
Save kamilZ/8518939 to your computer and use it in GitHub Desktop.
Android darken color.
public static int brighten(int color, double fraction) {
int red = (int) Math.round(Math.max(0,Color.red(color) - 255 * fraction));
int green = (int) Math.round(Math.max(0,Color.green(color) - 255 * fraction));
int blue = (int) Math.round(Math.max(0,Color.blue(color) - 255 * fraction));
return Color.argb(Color.alpha(color);, red, green, blue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment