Android examples for Graphics:Contrast Color
get Best Gray Contrast Color
//package com.java2s; import android.graphics.Color; public class Main { /**/*from w w w . jav a 2s . c o m*/ * @see {http://stackoverflow.com/questions/946544/good-text-foreground-color-for-a-given-background-color} * @param color * @return light or dark gray depending on the brightness of the color */ public static int getBestGrayContrast(int color) { return isDark(color) ? Color.LTGRAY : Color.DKGRAY; } public static boolean isDark(int color) { int valuedColor = Color.red(color) * 299 + Color.green(color) * 587 + Color.blue(color) * 114; return valuedColor < 186000; } }