標籤:
Theme: 表單層級,改變表單樣式
style--<
style: 表單元素層級,改變指定控制項或者Layout的樣式。
建立自訂的style和theme:1.在res/values 目錄下建立名為style.xml的檔案2.增加一個<resources>根節點。
<resources> <style name="SpecialText" parent="@style/Text"> <item name="android:textSize">18sp</item> <item name="android:textColor">#008</item> </style></resources>
3. 後面就可以使用SpecialText來應用style4.item用於定義名字屬性,內部定義style的值(在Item當中的名字的屬性可以是一個字串,一個16進位數所表示的顏色或者是其他資源的引用。) 5.parent中的內容表示自訂的style直接或者間接地繼承Android的標準風格***********使用方法***********
<EditText id="@+id/text1" style="@style/SpecialText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Hello, World!" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~同style,theme依然在<style>中申明,也以同樣的方式引用。
<?xml version="1.0" encoding="utf-8"?><resources> <style name="CustomTheme"> <item name="android:windowNoTitle">true</item> <item name="windowFrame">@drawable/screen_frame</item> <item name="windowBackground">@drawable/screen_background_white</item> <item name="panelForegroundColor">#FF000000</item> <item name="panelBackgroundColor">#FFFFFFFF</item> <item name="panelTextColor">?panelForegroundColor</item> <item name="panelTextSize">14</item> <item name="menuItemTextColor">?panelTextColor</item> <item name="menuItemTextSize">?panelTextSize</item> </style></resources>
**應用資源的位置@符號:表示應用的資源是前邊定義過的(或者在前一個項目中或者在Android 架構中)。? 表明了引用的資源的值在當前的主題當中定義過。通過引用在<item>裡邊定義的名字可以做到(
panelTextColor 用的顏色和
panelForegroundColor中定義的一樣)。這中技巧只能用在XML資源當中。 ****注意,Theme必須在Manifest中設定主題----下回再學學習資料來源:http://zyfromcq.iteye.com/blog/1401710
Android ----style