The developerβs guide explains how to apply themes and styles.
It:
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#00FF00" android:typeface="monospace" android:text="@string/hello" />
Becomes as follows:
<TextView style="@style/CodeFont" android:text="@string/hello" />
Having defined the xml theme file:
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="CodeFont" parent="@android:style/TextAppearance.Medium"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:textColor">#00FF00</item> <item name="android:typeface">monospace</item> </style> </resources>
You can also apply styles in all actions of the application:
<application android:theme="@style/CustomTheme">
Or just one action:
<activity android:theme="@android:style/Theme.Dialog">
Bryan denny
source share