[Android] android custom styles and themes, android

Source: Internet
Author: User

[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" >

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.