(1) Layout file
<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:paddi ngbottom= "@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 "> <!--Normal style usage--<textview android:id=" @+id/textview2 "Android:layout_wi Dth= "Wrap_content" android:layout_height= "wrap_content" android:layout_alignleft= "@+id/textView1" and roid:layout_below= "@+id/textview1" android:layout_margintop= "31DP" android:text= "@string/hello_world"/> <!--custom style usage--<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>
(2) Create a new XML file in values
<?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" > <i TEM 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_ma Rgintop ">48dp</item> <itEM name= "Android:layout_marginleft" >148dp</item> </style> <color name= "TextColor" > #ACBDEC < /color> <!--custom theme needs to modify the Android default theme in the manifest file--<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>
(3) If you want to modify the Android default theme needs to be modified in the manifest file, the circled position is the place that needs to be modified
(4) Other Ask Kim can be the default without modification!
Android Learning notes Theme Theme modification settings