Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ApplyColor method for a tutorial on the SSaurel's Blog
private void applyColor(String hexaTime) {
int color = Color.parseColor(hexaTime);
root.setBackgroundColor(color);
// white or black color for the text view
int tmp = (int) (0.2126 * Color.red(color)) + (int) (0.7152 * Color.green(color)) + (int) (0.0722 * Color.blue(color));
timeTv.setText(hexaTime);
timeTv.setTextColor(tmp < 128 ? Color.WHITE : Color.BLACK);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment