Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Shilo/560bb4ea5e41f5bb06f82f0cc90e0721 to your computer and use it in GitHub Desktop.
Save Shilo/560bb4ea5e41f5bb06f82f0cc90e0721 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