Color.BLACK~Color.TRANSPARENT
@ColorInt public static final int BLACK = 0xFF000000; //黑色
@ColorInt public static final int DKGRAY = 0xFF444444; //灰色
@ColorInt public static final int GRAY = 0xFF888888; //灰色
@ColorInt public static final int LTGRAY = 0xFFCCCCCC; //灰色
@ColorInt public static final int WHITE = 0xFFFFFFFF; //白色
@ColorInt public static final int RED = 0xFFFF0000; //红色
@ColorInt public static final int GREEN = 0xFF00FF00; //绿色
@ColorInt public static final int BLUE = 0xFF0000FF; //蓝色
@ColorInt public static final int YELLOW = 0xFFFFFF00; //黄色
@ColorInt public static final int CYAN = 0xFF00FFFF; //青色
@ColorInt public static final int MAGENTA = 0xFFFF00FF; //洋红色
@ColorInt public static final int TRANSPARENT = 0; //透明的
Color.``_argb_``(alpha``,``red``,``green``,``blue)``;
源码:
public static int argb(
@IntRange(from = 0, to = 255) int alpha,
@IntRange(from = 0, to = 255) int red,
@IntRange(from = 0, to = 255) int green,
@IntRange(from = 0, to = 255) int blue) {
return (alpha << 24) | (red << 16) | (green << 8) | blue;
}
@ColorInt
public static int argb(float alpha, float red, float green, float blue) {
return ((int) (alpha * 255.0f + 0.5f) << 24) |
((int) (red * 255.0f + 0.5f) << 16) |
((int) (green * 255.0f + 0.5f) << 8) |
(int) (blue * 255.0f + 0.5f);
}
Color.``rgb(float red, float green, float blue)
源码:
@ColorInt
public static int rgb(
@IntRange(from = 0, to = 255) int red,
@IntRange(from = 0, to = 255) int green,
@IntRange(from = 0, to = 255) int blue) {
return 0xff000000 | (red << 16) | (green << 8) | blue;
}
@ColorInt
public static int rgb(float red, float green, float blue) {
return 0xff000000 |
((int) (red * 255.0f + 0.5f) << 16) |
((int) (green * 255.0f + 0.5f) << 8) |
(int) (blue * 255.0f + 0.5f);
}