style 使用
style
[功能]
style 就像 模板 即 一些属性的集合
[使用]
1. 定义一种 style 名字为 SpecialText 放在 style.xml 中
<?xml version="1.0" encoding="utf-8"?><resources> <style name="SpecialText" > <item name="android:textSize">28sp</item> <item name="android:textColor">@color/darkgreen</item> <item name="android:gravity">center</item> <item name="android:textStyle">bold|italic</item> <item name="android:background">@drawable/dot</item> </style></resources>
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" ><TextView style="@style/SpecialText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /></LinearLayout>
<item name="android:textColor">@color/darkgreen</item>
<?xml version="1.0" encoding="utf-8"?><resources> <string name="hello">welcome to Android worlds!</string> <string name="app_name">StylesUsage</string> <color name="transparent_background">#0000FF</color> <color name="translucent_background">#C2CE99</color> <color name="blue">#0000FF</color> <color name="white">#FFFFFF</color> <color name="pink">#FFC8FF</color> <color name="darkgreen">#008800</color></resources>