样式化的定型对象

类似于CSS的方法,例如
main.xml
<TextView
      style="@style/StyleText1"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:gravity="center_vertical|center_horizontal"
      android:text="@string/str_text1"
      />
    <TextView
      style="@style/StyleText2"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:gravity="center_vertical|center_horizontal"
      android:text="@string/str_text2"
      />
res/values/style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <style name="StyleText1">
      <item name="android:textSize">18sp</item>
      <item name="android:textColor">#EC9237</item>
   </style>
   <style name="StyleText2">
      <item name="android:textSize">14sp</item>
      <item name="android:textColor">#FF7F7C</item>
      <item name="android:fromAlpha">0.0</item>
      <item name="android:toAlpha">0.0</item>
   </style>
</resources>

你可能感兴趣的:(xml,css)