同时,SDK中提供了Color这个类,在这个类中只是定义了一些常用的颜色值,如下所示
public static final int BLACK = 0xFF000000;
public static final int DKGRAY = 0xFF444444;
public static final int GRAY = 0xFF888888;
public static final int LTGRAY = 0xFFCCCCCC;
public static final int WHITE = 0xFFFFFFFF;
public static final int RED = 0xFFFF0000;
public static final int GREEN = 0xFF00FF00;
public static final int BLUE = 0xFF0000FF;
public static final int YELLOW = 0xFFFFFF00;
public static final int CYAN = 0xFF00FFFF;
public static final int MAGENTA = 0xFFFF00FF;
在Color这个类中,还有一些常用的方法,可以分成三类:
(1)获取颜色color的RGB属性
alpha(int color) Return the alpha component of a color int.
blue(int color) Return the blue component of a color int.
green(int color) Return the green component of a color int.
red(int color) Return the red component of a color int.
(2)根据RGB三个参数,或者加上透明度参数合成得到color的值
parseColor(String colorString) Parse the color string, and return the corresponding color-int.
rgb(int red, int green, int blue) Return a color-int from red, green, blue components.
argb(int alpha, int red, int green, int blue) Return a color-int from alpha, red, green, blue components.
(3)RGB颜色值与HSV值的转换
HSVToColor(float[] hsv) Convert HSV components to an ARGB color.
HSVToColor(int alpha, float[] hsv) Convert HSV components to an ARGB color.
RGBToHSV(int red, int green, int blue, float[] hsv) Convert RGB components to HSV.
colorToHSV(int color, float[] hsv) Convert the argb color to its HSV components.