Created
October 9, 2017 08:44
-
-
Save ssaurel/75607ef6970d969fd31fb6d579a3f31e to your computer and use it in GitHub Desktop.
ApplyColor method for a tutorial on the SSaurel's Blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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