直接上代码
public boolean isLightColor(int color) { double darkness = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255; if (darkness < 0.5) { return true; // It's a light color } else { return false; // It's a dark color } }
参考:
http://stackoverflow.com/questions/3656586/android-how-to-get-background-color-of-activity-in-java