一、利於系統自帶的顏色類linux
如TextView1.setTextColor(Android.graphics.Color.RED);spring
二、數字顏色表示法shell
TextView1.setTextColor(0xffff00ff);網站
三、自定義顏色this
TextView1.setTextColor(this.getResources().getColor(R.drawable.red));url
我在values文件夾下新建一個color.xml,內容以下spa
1.<?xml version="1.0" encoding="utf-8"?>
2.<resources>
3.<drawable name="dkgray">#80808FF0</drawable>
4.<drawable name="yello">#F8F8FF00</drawable>
5.<drawable name="white">#FFFFFF</drawable>
6.<drawable name="darkgray">#938192</drawable>
7.<drawable name="lightgreen">#7cd12e</drawable>
8.<drawable name="black">#ff000000</drawable>
9.<drawable name="blue">#ff0000ff</drawable>
10.<drawable name="cyan">#ff00ffff</drawable>
11.<drawable name="gray">#ff888888</drawable>
12.<drawable name="green">#ff00ff00</drawable>
13.<drawable name="ltgray">#ffcccccc</drawable>
14.<drawable name="magenta">#ffff00ff</drawable>
15.<drawable name="red">#ffff0000</drawable>
16.<drawable name="transparent">#00000000</drawable>
17.<drawable name="yellow">#ffffff00</drawable>
18.</resources> rest
一個更全的顏色列表:xml
1.<?xml version="1.0" encoding="utf-8" ?>
2.<resources>
3.<color name="white">#FFFFFF</color><!--白色 -->
4.<color name="ivory">#FFFFF0</color><!--象牙色 -->
5.<color name="lightyellow">#FFFFE0</color><!--亮黃色 -->
6.<color name="yellow">#FFFF00</color><!--黃色 -->
7.<color name="snow">#FFFAFA</color><!--雪白色 -->
8.<color name="floralwhite">#FFFAF0</color><!--花白色 -->
9.<color name="lemonchiffon">#FFFACD</color><!--檸檬綢色 -->
10.<color name="cornsilk">#FFF8DC</color><!--米綢色 -->
11.<color name="seashell">#FFF5EE</color><!--海貝色 -->
12.<color name="lavenderblush">#FFF0F5</color><!--淡紫紅 -->
13.<color name="papayawhip">#FFEFD5</color><!--番木色 -->
14.<color name="blanchedalmond">#FFEBCD</color><!--白杏色 -->
15.<color name="mistyrose">#FFE4E1</color><!--淺玫瑰色 -->
16.<color name="bisque">#FFE4C4</color><!--桔黃色 -->
17.<color name="moccasin">#FFE4B5</color><!--鹿皮色 -->
18.<color name="navajowhite">#FFDEAD</color><!--納瓦白 -->
19.<color name="peachpuff">#FFDAB9</color><!--桃色 -->
20.<color name="gold">#FFD700</color><!--金色 -->
21.<color name="pink">#FFC0CB</color><!--粉紅色 -->
22.<color name="lightpink">#FFB6C1</color><!--亮粉紅色 -->
23.<color name="orange">#FFA500</color><!--橙色 -->
24.<color name="lightsalmon">#FFA07A</color><!--亮肉色 -->
25.<color name="darkorange">#FF8C00</color><!--暗桔黃色 -->
26.<color name="coral">#FF7F50</color><!--珊瑚色 -->
27.<color name="hotpink">#FF69B4</color><!--熱粉紅色 -->
28.<color name="tomato">#FF6347</color><!--西紅柿色 -->
29.<color name="orangered">#FF4500</color><!--紅橙色 -->
30.<color name="deeppink">#FF1493</color><!--深粉紅色 -->
31.<color name="fuchsia">#FF00FF</color><!--紫紅色 -->
32.<color name="magenta">#FF00FF</color><!--紅紫色 -->
33.<color name="red">#FF0000</color><!--紅色 -->
34.<color name="oldlace">#FDF5E6</color><!--老花色 -->
35.<color name="lightgoldenrodyellow">#FAFAD2</color><!--亮金黃色 -->
36.<color name="linen">#FAF0E6</color><!--亞麻色 -->
37.<color name="antiquewhite">#FAEBD7</color><!--古董白 -->
38.<color name="salmon">#FA8072</color><!--鮮肉色 -->
39.<color name="ghostwhite">#F8F8FF</color><!--幽靈白 -->
40.<color name="mintcream">#F5FFFA</color><!--薄荷色 -->
41.<color name="whitesmoke">#F5F5F5</color><!--煙白色 -->
42.<color name="beige">#F5F5DC</color><!--米色 -->
43.<color name="wheat">#F5DEB3</color><!--淺黃色 -->
44.<color name="sandybrown">#F4A460</color><!--沙褐色 -->
45.<color name="azure">#F0FFFF</color><!--天藍色 -->
46.<color name="honeydew">#F0FFF0</color><!--蜜色 -->
47.<color name="aliceblue">#F0F8FF</color><!--艾利斯蘭 -->
48.<color name="khaki">#F0E68C</color><!--黃褐色 -->
49.<color name="lightcoral">#F08080</color><!--亮珊瑚色 -->
50.<color name="palegoldenrod">#EEE8AA</color><!--蒼麒麟色 -->
51.<color name="violet">#EE82EE</color><!--紫羅蘭色 -->
52.<color name="darksalmon">#E9967A</color><!--暗肉色 -->
53.<color name="lavender">#E6E6FA</color><!--淡紫色 -->
54.<color name="lightcyan">#E0FFFF</color><!--亮青色 -->
55.<color name="burlywood">#DEB887</color><!--實木色 -->
56.<color name="plum">#DDA0DD</color><!--洋李色 -->
57.<color name="gainsboro">#DCDCDC</color><!--淡灰色 -->
58.<color name="crimson">#DC143C</color><!--暗深紅色 -->
59.<color name="palevioletred">#DB7093</color><!--蒼紫羅蘭色 -->
60.<color name="goldenrod">#DAA520</color><!--金麒麟色 -->
61.<color name="orchid">#DA70D6</color><!--淡紫色 -->
62.<color name="thistle">#D8BFD8</color><!--薊色 -->
63.<color name="lightgray">#D3D3D3</color><!--亮灰色 -->
64.<color name="lightgrey">#D3D3D3</color><!--亮灰色 -->
65.<color name="tan">#D2B48C</color><!--茶色 -->
66.<color name="chocolate">#D2691E</color><!--巧可力色 -->
67.<color name="peru">#CD853F</color><!--祕魯色 -->
68.<color name="indianred">#CD5C5C</color><!--印第安紅 -->
69.<color name="mediumvioletred">#C71585</color><!--中紫羅蘭色 -->
70.<color name="silver">#C0C0C0</color><!--銀色 -->
71.<color name="darkkhaki">#BDB76B</color><!--暗黃褐色 -->
72.<color name="rosybrown">#BC8F8F</color><!--褐玫瑰紅 -->
73.<color name="mediumorchid">#BA55D3</color><!--中粉紫色 -->
74.<color name="darkgoldenrod">#B8860B</color><!--暗金黃色 -->
75.<color name="firebrick">#B22222</color><!--火磚色 -->
76.<color name="powderblue">#B0E0E6</color><!--粉藍色 -->
77.<color name="lightsteelblue">#B0C4DE</color><!--亮鋼蘭色 -->
78.<color name="paleturquoise">#AFEEEE</color><!--蒼寶石綠 -->
79.<color name="greenyellow">#ADFF2F</color><!--黃綠色 -->
80.<color name="lightblue">#ADD8E6</color><!--亮藍色 -->
81.<color name="darkgray">#A9A9A9</color><!--暗灰色 -->
82.<color name="darkgrey">#A9A9A9</color><!--暗灰色 -->
83.<color name="brown">#A52A2A</color><!--褐色 -->
84.<color name="sienna">#A0522D</color><!--赭色 -->
85.<color name="darkorchid">#9932CC</color><!--暗紫色 -->
86.<color name="palegreen">#98FB98</color><!--蒼綠色 -->
87.<color name="darkviolet">#9400D3</color><!--暗紫羅蘭色 -->
88.<color name="mediumpurple">#9370DB</color><!--中紫色 -->
89.<color name="lightgreen">#90EE90</color><!--亮綠色 -->
90.<color name="darkseagreen">#8FBC8F</color><!--暗海蘭色 -->
91.<color name="saddlebrown">#8B4513</color><!--重褐色 -->
92.<color name="darkmagenta">#8B008B</color><!--暗洋紅 -->
93.<color name="darkred">#8B0000</color><!--暗紅色 -->
94.<color name="blueviolet">#8A2BE2</color><!--紫羅蘭藍色 -->
95.<color name="lightskyblue">#87CEFA</color><!--亮天藍色 -->
96.<color name="skyblue">#87CEEB</color><!--天藍色 -->
97.<color name="gray">#808080</color><!--灰色 -->
98.<color name="grey">#808080</color><!--灰色 -->
99.<color name="olive">#808000</color><!--橄欖色 -->
100.<color name="purple">#800080</color><!--紫色 -->
101.<color name="maroon">#800000</color><!--粟色 -->
102.<color name="aquamarine">#7FFFD4</color><!--碧綠色 -->
103.<color name="chartreuse">#7FFF00</color><!--黃綠色 -->
104.<color name="lawngreen">#7CFC00</color><!--草綠色 -->
105.<color name="mediumslateblue">#7B68EE</color><!--中暗藍色 -->
106.<color name="lightslategray">#778899</color><!--亮藍灰 -->
107.<color name="lightslategrey">#778899</color><!--亮藍灰 -->
108.<color name="slategray">#708090</color><!--灰石色 -->
109.<color name="slategrey">#708090</color><!--灰石色 -->
110.<color name="olivedrab">#6B8E23</color><!--深綠褐色 -->
111.<color name="slateblue">#6A5ACD</color><!--石藍色 -->
112.<color name="dimgray">#696969</color><!--暗灰色 -->
113.<color name="dimgrey">#696969</color><!--暗灰色 -->
114.<color name="mediumaquamarine">#66CDAA</color><!--中綠色 -->
115.<color name="cornflowerblue">#6495ED</color><!--菊蘭色 -->
116.<color name="cadetblue">#5F9EA0</color><!--軍蘭色 -->
117.<color name="darkolivegreen">#556B2F</color><!--暗橄欖綠 -->
118.<color name="indigo">#4B0082</color><!--靛青色 -->
119.<color name="mediumturquoise">#48D1CC</color><!--中綠寶石 -->
120.<color name="darkslateblue">#483D8B</color><!--暗灰藍色 -->
121.<color name="steelblue">#4682B4</color><!--鋼蘭色 -->
122.<color name="royalblue">#4169E1</color><!--皇家藍 -->
123.<color name="turquoise">#40E0D0</color><!--青綠色 -->
124.<color name="mediumseagreen">#3CB371</color><!--中海藍 -->
125.<color name="limegreen">#32CD32</color><!--橙綠色 -->
126.<color name="darkslategray">#2F4F4F</color><!--暗瓦灰色 -->
127.<color name="darkslategrey">#2F4F4F</color><!--暗瓦灰色 -->
128.<color name="seagreen">#2E8B57</color><!--海綠色 -->
129.<color name="forestgreen">#228B22</color><!--森林綠 -->
130.<color name="lightseagreen">#20B2AA</color><!--亮海藍色 -->
131.<color name="dodgerblue">#1E90FF</color><!--閃蘭色 -->
132.<color name="midnightblue">#191970</color><!--中灰蘭色 -->
133.<color name="aqua">#00FFFF</color><!--淺綠色 -->
134.<color name="cyan">#00FFFF</color><!--青色 -->
135.<color name="springgreen">#00FF7F</color><!--春綠色 -->
136.<color name="lime">#00FF00</color><!--酸橙色 -->
137.<color name="mediumspringgreen">#00FA9A</color><!--中春綠色 -->
138.<color name="darkturquoise">#00CED1</color><!--暗寶石綠 -->
139.<color name="deepskyblue">#00BFFF</color><!--深天藍色 -->
140.<color name="darkcyan">#008B8B</color><!--暗青色 -->
141.<color name="teal">#008080</color><!--水鴨色 -->
142.<color name="green">#008000</color><!--綠色 -->
143.<color name="darkgreen">#006400</color><!--暗綠色 -->
144.<color name="blue">#0000FF</color><!--藍色 -->
145.<color name="mediumblue">#0000CD</color><!--中蘭色 -->
146.<color name="darkblue">#00008B</color><!--暗藍色 -->
147.<color name="navy">#000080</color><!--海軍色 -->
148.<color name="black">#000000</color><!--黑色 -->
149.</resources> htm
本篇文章來源於 Linux公社網站(www.linuxidc.com) 原文連接:http://www.linuxidc.com/Linux/2012-04/58697.htm