如何在XML设定android控件的颜色(十六进制颜色码)

我的博文地址
xml中Android控件设定背景颜色或字体颜色,需要在Color属性中指定十六进制颜色码。
如设置背景颜色:android:background=”#FF0000”;//红色
设置字体颜色:android:textColor=”#87CEEB”;//天蓝色
其中需要重要说明的是如何设置控件背景透明,如代码:
android:background=”@android:color/transparent” //设置背景色透明
以下列出比较常用的颜色:
android:background=”#ffffff”; //纯白
android:background=”#000000”; //纯黑
点击这里查看,十六进制颜色码详细表
下面给大家一些String颜色的应用:

   
<resources>   
<color name="transparent">#00000000color>   
<color name="white">#FFFFFFcolor>   
<color name="ivory">#FFFFF0color>   
<color name="lightyellow">#FFFFE0color>   
<color name="yellow">#FFFF00color>   
<color name="snow">#FFFAFAcolor>   
<color name="floralwhite">#FFFAF0color>   
<color name="lemonchiffon">#FFFACDcolor>   
<color name="cornsilk">#FFF8DCcolor>   
<color name="seashell">#FFF5EEcolor>   
<color name="lavenderblush">#FFF0F5color>   
<color name="papayawhip">#FFEFD5color>   
<color name="blanchedalmond">#FFEBCDcolor>   
<color name="mistyrose">#FFE4E1color>   
<color name="bisque">#FFE4C4color>   
<color name="moccasin">#FFE4B5color>   
<color name="navajowhite">#FFDEADcolor>   
<color name="peachpuff">#FFDAB9color>   
<color name="gold">#FFD700color>   
<color name="pink">#FFC0CBcolor>   
<color name="lightpink">#FFB6C1color>   
<color name="orange">#FFA500color>   
<color name="lightsalmon">#FFA07Acolor>   
<color name="darkorange">#FF8C00color>   
<color name="coral">#FF7F50color>   
<color name="hotpink">#FF69B4color>   
<color name="tomato">#FF6347color>   
<color name="orangered">#FF4500color>   
<color name="deeppink">#FF1493color>   
<color name="fuchsia">#FF00FFcolor>    
<color name="red">#FF0000color>   
<color name="oldlace">#FDF5E6color>   
<color name="lightgoldenrodyellow">#FAFAD2color>   
<color name="linen">#FAF0E6color>   
<color name="antiquewhite">#FAEBD7color>   
<color name="salmon">#FA8072color>   
<color name="ghostwhite">#F8F8FFcolor>   
<color name="mintcream">#F5FFFAcolor>   
<color name="whitesmoke">#F5F5F5color>   
<color name="beige">#F5F5DCcolor>   
<color name="wheat">#F5DEB3color>   
<color name="sandybrown">#F4A460color>   
<color name="azure">#F0FFFFcolor>   
<color name="honeydew">#F0FFF0color>   
<color name="aliceblue">#F0F8FFcolor>   
<color name="khaki">#F0E68Ccolor>   
<color name="lightcoral">#F08080color>   
<color name="palegoldenrod">#EEE8AAcolor>   
<color name="violet">#EE82EEcolor>   
<color name="darksalmon">#E9967Acolor>   
<color name="lavender">#E6E6FAcolor>   
<color name="lightcyan">#E0FFFFcolor>   
<color name="burlywood">#DEB887color>   
<color name="plum">#DDA0DDcolor>   
<color name="gainsboro">#DCDCDCcolor>   
<color name="crimson">#DC143Ccolor>   
<color name="palevioletred">#DB7093color>   
<color name="goldenrod">#DAA520color>   
<color name="orchid">#DA70D6color>   
<color name="thistle">#D8BFD8color>   
<color name="lightgray">#D3D3D3color>   
<color name="tan">#D2B48Ccolor>   
<color name="chocolate">#D2691Ecolor>   
<color name="peru">#CD853Fcolor>   
<color name="indianred">#CD5C5Ccolor>   
<color name="mediumvioletred">#C71585color>   
<color name="silver">#C0C0C0color>   
<color name="darkkhaki">#BDB76Bcolor>   
<color name="rosybrown">#BC8F8Fcolor>   
<color name="mediumorchid">#BA55D3color>   
<color name="darkgoldenrod">#B8860Bcolor>   
<color name="firebrick">#B22222color>   
<color name="powderblue">#B0E0E6color>   
<color name="lightsteelblue">#B0C4DEcolor>   
<color name="paleturquoise">#AFEEEEcolor>   
<color name="greenyellow">#ADFF2Fcolor>   
<color name="lightblue">#ADD8E6color>   
<color name="darkgray">#A9A9A9color>   
<color name="brown">#A52A2Acolor>   
<color name="sienna">#A0522Dcolor>   
<color name="darkorchid">#9932CCcolor>   
<color name="palegreen">#98FB98color>   
<color name="darkviolet">#9400D3color>   
<color name="mediumpurple">#9370DBcolor>   
<color name="lightgreen">#90EE90color>   
<color name="darkseagreen">#8FBC8Fcolor>   
<color name="saddlebrown">#8B4513color>   
<color name="darkmagenta">#8B008Bcolor>   
<color name="darkred">#8B0000color>   
<color name="blueviolet">#8A2BE2color>   
<color name="lightskyblue">#87CEFAcolor>   
<color name="skyblue">#87CEEBcolor>   
<color name="gray">#808080color>   
<color name="olive">#808000color>   
<color name="purple">#800080color>   
<color name="maroon">#800000color>   
<color name="aquamarine">#7FFFD4color>   
<color name="chartreuse">#7FFF00color>   
<color name="lawngreen">#7CFC00color>   
<color name="mediumslateblue">#7B68EEcolor>   
<color name="lightslategray">#778899color>   
<color name="slategray">#708090color>   
<color name="olivedrab">#6B8E23color>   
<color name="slateblue">#6A5ACDcolor>   
<color name="dimgray">#696969color>   
<color name="mediumaquamarine">#66CDAAcolor>   
<color name="cornflowerblue">#6495EDcolor>   
<color name="cadetblue">#5F9EA0color>   
<color name="darkolivegreen">#556B2Fcolor>   
<color name="indigo">#4B0082color>   
<color name="mediumturquoise">#48D1CCcolor>   
<color name="darkslateblue">#483D8Bcolor>   
<color name="steelblue">#4682B4color>   
<color name="royalblue">#4169E1color>   
<color name="turquoise">#40E0D0color>   
<color name="mediumseagreen">#3CB371color>   
<color name="limegreen">#32CD32color>   
<color name="darkslategray">#2F4F4Fcolor>   
<color name="seagreen">#2E8B57color>   
<color name="forestgreen">#228B22color>   
<color name="lightseagreen">#20B2AAcolor>   
<color name="dodgerblue">#1E90FFcolor>   
<color name="midnightblue">#191970color>   
<color name="aqua">#00FFFFcolor>   
<color name="cyan">#00FFFFcolor>   
<color name="springgreen">#00FF7Fcolor>   
<color name="lime">#00FF00color>   
<color name="mediumspringgreen">#00FA9Acolor>   
<color name="darkturquoise">#00CED1color>   
<color name="deepskyblue">#00BFFFcolor>   
<color name="darkcyan">#008B8Bcolor>   
<color name="teal">#008080color>   
<color name="green">#008000color>   
<color name="darkgreen">#006400color>   
<color name="blue">#0000FFcolor>   
<color name="mediumblue">#0000CDcolor>   
<color name="darkblue">#00008Bcolor>   
<color name="navy">#000080color>   
<color name="black">#000000color>   
<color name="grassgreen">#99cc33color> 
<color name="gray_cc">#cccccccolor>   
<color name="gray_8f">#8f8f8fcolor>   
resources>  

你可能感兴趣的:(如何在XML设定android控件的颜色(十六进制颜色码))