Skip to content

Instantly share code, notes, and snippets.

@vinaysshenoy
Created March 1, 2015 06:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vinaysshenoy/f54a208ad93b10e94a3a to your computer and use it in GitHub Desktop.
Save vinaysshenoy/f54a208ad93b10e94a3a to your computer and use it in GitHub Desktop.
Android check if color is dark
public boolean isColorDark(int color){
double darkness = 1-(0.299*Color.red(color) + 0.587*Color.green(color) + 0.114*Color.blue(color))/255;
if(darkness<0.5){
return false; // It's a light color
}else{
return true; // It's a dark color
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment