樣式跟主題
簡單說類似與自定義控件,只不過自定義控件針對的是view 而樣式與主題針對的是屬性、元素
在TexvView中引入樣式
layout.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView style="@style/text_content_style" android:text="haha" /> <TextView style="@style/text_content_style" android:text="gaga" /> <TextView style="@style/text_red_content_style" android:text="guagua" /> </LinearLayout>
引入的樣式的.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="text_content_style">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#66ff00</item>
<item name="android:textSize">28sp</item>
</style>
<style name="text_red_content_style" parent="@style/text_content_style">
<item name="android:textColor">#ff0000</item>
</style>
<style name="activity_bg_theme">
<item name="android:background">#ff0000</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>

浙公網安備 33010602011771號