(1)布局文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <!-- 普通的样式使用方法 --> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/textView1" android:layout_marginTop="31dp" android:text="@string/hello_world" /> <!-- 自定义的样式使用方法 --> <TextView android:id="@+id/textView1" style="@style/CodeFont.RED.BIG" android:text="@string/hello_world" /> <Button android:id="@+id/button1" style="@style/buttonStyle" android:layout_alignLeft="@+id/textView2" android:layout_centerVertical="true" android:text="Button" android:textColor="@color/textColor" /> </RelativeLayout>
<?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <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:typeface">monospace</item> </style> <style name="CodeFont.RED"> <item name="android:textColor">#00FF00</item> </style> <style name="CodeFont.RED.BIG"> <item name="android:textSize">20sp</item> </style> <style name="buttonStyle"> <item name="android:textColor">#00FF00</item> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_marginTop">48dp</item> <item name="android:layout_marginLeft">148dp</item> </style> <color name="textColor">#ACBDEC</color> <!-- 自定义主题 需要在清单文件中修改Android默认的主题 --> <color name="custom_theme_color">#b0b0ff</color> <style name="CustomTheme" parent="android:Theme.Light"> <item name="android:windowBackground">@color/custom_theme_color</item> <item name="android:colorBackground">@color/custom_theme_color</item> </style> </resources>
(4)其他问阿金都可以默认无需修改!
原文地址:http://blog.csdn.net/xlgen157387/article/details/42778617