[Android] android custom styles and themes, android
Simple exercises customize styles and themes. styles are added to the View, and themes are added to the Application or Activity.
Styles. xml
<? Xml version = "1.0" encoding = "UTF-8"?> <Resources xmlns: android = "http://schemas.android.com/apk/res/android"> <! -- Custom style --> <style name = "MyFont"> <item name = "android: textColor"> # ff0000 </item> <item name = "android: textSize "> 40sp </item> </style> <style name =" MyFontSon "parent =" @ style/MyFont "> <item name =" android: textSize "> 30sp </item> </style> <! -- Custom topic --> <style name = "MyTheme"> <item name = 'android: windownotitle'> true </item> <item name = "android: background "> # ffffff </item> </style> </resources>
Activity_main.xml
<? Xml version = "1.0" encoding = "UTF-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "match_parent" android: orientation = "vertical"> <TextView style = "@ style/MyFont" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: text = "style and topic"/> <TextView style = "@ style/MyFontSon" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: text = "style and topic"/> </LinearLayout>
Manifest. xml
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="ss" android:theme="@style/MyTheme" >