谷歌的文档很不错
Styles and Themes
Android Styles
Android Themes
摘录一些重点备忘
- A style is a collection of properties that specify the look and format for a View or window.
- To create a set of styles, save an XML file in the res/values/ directory of your project.
- The parent attribute in the <style> element lets you specify a style from which your style should inherit properties.
- If you want to inherit from styles that you've defined yourself, you do not have to use the parent attribute. Instead, just prefix the name of the style you want to inherit to the name of your new style, separated by a period.
- To set a theme for all the activities of your application, open the AndroidManifest.xml file and edit the <application> tag to include the android:theme attribute with the style name.
- If you want a theme applied to just one Activity in your application, then add the android:theme attribute to the <activity> tag instead.
最后还是上点代码
<?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>
<style name="CodeFont.Red">
<item name="android:textColor">#FF0000</item>
</style>
<style name="CodeFont.Red">
<item name="android:textColor">#FF0000</item>
</style>
</resources>
<application android:theme="@style/CustomTheme">
<activity android:theme="@android:style/Theme.Translucent">
网友评论