在程式中很常需要替文字或是背景選擇顏色,所以必須透過android的layout機制。

color  

step1.新增color.xml於res/values/color.xml下,並定義顏色。

color.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="blue">#FF0000FF</color>
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
</resources>

step2.在layout中引用顏色

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
>

arrow
arrow

    S 發表在 痞客邦 留言(0) 人氣()