Android ----style

來源:互聯網
上載者:User

標籤:

 

     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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.