Android examples for Graphics:Contrast Color
get Contrast Color
//package com.java2s; import android.graphics.Color; public class Main { public static int getContrastColor(String colorString) { int color = Color.parseColor(colorString); double y = (299 * Color.red(color) + 587 * Color.green(color) + 114 * Color .blue(color)) / 1000;/*from w w w.j ava 2s .c om*/ if (y >= 128) { return Color.BLACK; } else { return Color.WHITE; } } }