首页
社区
课程
招聘
[分享]Android颜色XML
发表于: 2011-12-12 21:24 8693

[分享]Android颜色XML

2011-12-12 21:24
8693
附件中为颜色的XML文件,这个比较全,直接用在Android项目中,比较方便!部分内容为下:
<color name="white">#FFFFFF</color>
<!--白色 -->
<color name="ivory">#FFFFF0</color>
<!--象牙色 -->
<color name="lightyellow">#FFFFE0</color>
<!--亮黄色 -->
<color name="yellow">#FFFF00</color>
<!--黄色 -->

同时,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.

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

上传的附件:
收藏
免费 0
支持
分享
最新回复 (4)
雪    币: 32
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
不错到资源~
2013-3-24 14:57
0
雪    币: 80
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
回家再下载下来放到俺的毕业设计上去
2013-3-27 11:29
0
雪    币: 298
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
记得参考里注明:沙加L@pediy
2013-3-27 11:51
0
雪    币: 37
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
谢谢分享!!
2013-4-4 22:35
0
游客
登录 | 注册 方可回帖
返回
//