Android style and theme.

Source: Internet
Author: User
More and more Internet enterprises are deploying their clients on the Android platform. To improve user experience, these clients are well-organized and beautiful ....... android style design is one of the keys to improve user experience. The style on Android is divided into two aspects: theme is for the form level and changes the form style; style is for the form Element Level, and changes the style of the specified control or layout. Themes. XML and style. XML (located in/base/CORE/RES/values/) contains many styles defined by the system. We recommend that you select an appropriate style and then inherit and modify it. The following attributes are common in themes, which are derived from themes. xml of the Android system: [XHTML] view plaincopyprint? <! -- Window Attributes --> <item name = "windowbackground"> @ Android: drawable/screen_background_dark </item> <item name = "windowframe"> @ null </item> <item name = "windownotitle"> false </item> <item name = "windowfullscreen "> false </item> <item name =" windowisfloating "> false </item> <item name =" windowcontentoverlay "> @ Android: drawable/title_bar_shadow </item> <item name = "windowtitlestyle"> @ Android: style/windowtitle </ Item> <item name = "windowtitlesize"> 25dip </item> <item name = "windowtitlebackgroundstyle"> @ Android: style/windowtitlebackground </item> <item name = "Android: windowanimationstyle "> @ Android: style/animation. activity </item> [XHTML] view plaincopy <! -- Window Attributes --> <item name = "windowbackground"> @ Android: drawable/screen_background_dark </item> <item name = "windowframe"> @ null </item> <item name = "windownotitle"> false </item> <item name = "windowfullscreen "> false </item> <item name =" windowisfloating "> false </item> <item name =" windowcontentoverlay "> @ Android: drawable/title_bar_shadow </item> <item name = "windowtitlestyle"> @ Android: style/windowtitle </ Item> <item name = "windowtitlesize"> 25dip </item> <item name = "windowtitlebackgroundstyle"> @ Android: style/windowtitlebackground </item> <item name = "Android: windowanimationstyle "> @ Android: style/animation. activity </item> As for the style design of the control, there is a majority of scope. Look at eclipse's Android control Attribute Editor [properties] and you will probably know which items are there, while Android's built-in style. XML only defines the default style of each control .... however, it is not recommended to change the style of the control. The Readable style makes it easier for users to use the software for a long time. In addition, the styleof the controller is used in many situations to 9.png. To learn 9.png, you must go to/base/CORE/RES/drawable-hdpito see that there are many systems in 9.png. PS: To study the style and theme of Android, it is strongly recommended to download the base. Git of Android! Next let's take a look at the program in this article: The themes. XML code of the program in this article is as follows, custom windowtitle,: <? XML version = "1.0" encoding = "UTF-8"?> <Resources> <! -- Inherit the built-in theme of Android. light, located in/base/CORE/RES/values/themes. XML --> <style name = "theme" parent = "Android: theme. light "> <item name =" Android: windowfullscreen "> true </item> <item name =" Android: windowtitlesize "> 60dip </item> <item name =" Android: windowtitlestyle "> @ style/windowtitle </item> </style> <style name =" windowtitle "parent =" Android: windowtitle "> <item name =" Android: singleline "> true </item> <item Nam E = "Android: shadowcolor" ># bb000000 </item> <item name = "Android: shadowradius "> 2.75 </item> </style> </resources> to use theme for an activity, either use the code settheme (R. style. theme), or set it in application manifest. The styles.xmlcode of this program is as follows: background.pdf uses 9.png, and XML is defined under/base/CORE/RES/drawable/: <? XML version = "1.0" encoding = "UTF-8"?> <Resources> <style name = "textview"> <item name = "Android: textsize"> 18sp </item> <item name = "Android: textcolor "> #008 </item> <item name =" Android: shadowcolor "> @ Android: color/Black </item> <item name =" Android: shadowradius "> 2.0 </item> </style> <style name =" edittext "> <item name =" Android: shadowcolor ">@android: color/Black </item> <item name = "Android: shadowradius"> 1.0 </item> <item name = "Android: background"> @ Droid: drawable/btn_default </item> <item name = "Android: textappearance">? Android: ATTR/textappearancemedium </item> </style> <style name = "button"> <item name = "Android: background" >@android: drawable/edit_text </item> <item name = "Android: textappearance">? Android: ATTR/textappearancemedium </item> </style> </resources> The main. XML Code is as follows: [XHTML] view plaincopyprint? <? XML version = "1.0" encoding = "UTF-8"?> <Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Orientation = "vertical" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"> <textview Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: text = "@ string/Hello" style = "@ style/textview"/> <edittext Android: id = "@ + ID/edittext01" Android: layout_height = "wrap_content" style = "@ St YLE/edittext "Android: layout_width =" fill_parent "Android: text =" edittext similar to a button "> </edittext> <edittext Android: id = "@ + ID/edittext02" Android: layout_height = "wrap_content" Android: layout_width = "fill_parent" Android: TEXT = "normal edittext"> </edittext> <button Android: Id = "@ + ID/button01" Android: layout_height = "wrap_content" style = "@ style/button" Android: layout_width = "fill_parent" Android: text = "Bu similar to edittext Tton "> </button> </linearlayout> [XHTML] view plaincopy <? XML version = "1.0" encoding = "UTF-8"?> <Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Orientation = "vertical" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"> <textview Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: text = "@ string/Hello" style = "@ style/textview"/> <edittext Android: id = "@ + ID/edittext01" Android: layout_height = "wrap_content" style = "@ style/edittext" Android: layout_width = "fill_parent" Android: TEXT = "edittext similar to button"> </edittext> <edittext Android: Id = "@ + ID/edittext02" Android: layout_height = "wrap_content" Android: layout_width = "fill_parent" Android: text = "normal edittext"> </edittext> <button Android: Id = "@ + ID/button01" Android: layout_height = "wrap_content" style = "@ style/button" Android: layout_width = "fill_parent" Android: text = "button similar to edittext"> </button> </linearlayout>
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.