Android examples for Graphics:Background Color
get Text Color from background color
//package com.java2s; import android.graphics.Color; public class Main { public static Integer getTextColor(Integer backgroundColor) { int[] rgb = { Color.red(backgroundColor), Color.green(backgroundColor), Color.blue(backgroundColor) }; int brightness = (int) Math.sqrt(rgb[0] * rgb[0] * .241 + rgb[1] * rgb[1] * .691 + rgb[2] * rgb[2] * .068); if (brightness >= 220) { return 0xFF000000; }/* ww w. ja v a2s. com*/ return 0xFFFFFFFF; } }