Getting started with Android (27th) -- style and theme)

Source: Internet
Author: User

This article comes fromHttp://blog.csdn.net/hellogv/, The reference must indicate the source!

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:

    1. Theme is for the form level and changes the form style;
    2. The 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 and are derived from themes. xml of the Android system:

View plain Copy to clipboard Print ?
  1. <! -- Window Attributes -->
  2. <Item Name="Windowbackground">@ Android: drawable/screen_background_dark</Item>
  3. <Item Name="Windowframe">@ Null</Item>
  4. <Item Name="Windownotitle">False</Item>
  5. <Item Name="Windowfullscreen">False</Item>
  6. <Item Name="Windowisfloating">False</Item>
  7. <Item Name="Windowcontentoverlay">@ Android: drawable/title_bar_shadow</Item>
  8. <Item Name="Windowtitlestyle">@ Android: style/windowtitle</Item>
  9. <Item Name="Windowtitlesize">25dip</Item>
  10. <Item Name="Windowtitlebackgroundstyle">@ Android: style/windowtitlebackground</Item>
  11. <Item Name="Android: windowanimationstyle">@ Android: style/animation. Activity</Item>

<! -- Window Attributes --> <br/> <item name = "windowbackground"> @ Android: drawable/screen_background_dark </item> <br/> <item name = "windowframe"> @ null </item> <br/> <item name = "windownotitle"> false </ item> <br/> <item name = "windowfullscreen"> false </item> <br/> <item name = "windowisfloating"> false </item> <br/> <item name = "windowcontentoverlay"> @ Android: drawable/title_bar_shadow </item> <br/> <item name = "windowtitlestyle"> @ Android: style/windowtitle </item> <br/> <item name = "windowtitlesize"> 25dip </item> <br/> <item name = "windowtitlebackgroundstyle"> @ Android: style/windowtitlebackground </item> <br/> <item name = "Android: windowanimationstyle"> @ Android: style/animation. activity </item>

 

As for the style design of the control, the scope is mostly,Check eclipse's Android control property editor [properties] to find out which entries are available.Android built-in style. xml only defines the default style of each control... however, it is not recommended to modify the style of the control. The Readable style allows 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 this articleProgramOf:

Themes. xmlCodeWindows title is customized as follows ,:

 

<? XML version = "1.0" encoding = "UTF-8"?>
<Resources>
<! -- Inherit the built-in theme. Light of Android, which is 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 name = "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"> @ Android: 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:

View plain Copy to clipboard Print ?
  1. <?XML Version="1.0" Encoding="UTF-8"?>
  2. <Linearlayout Xmlns: Android=Http://schemas.android.com/apk/res/android"
  3. Android: Orientation="Vertical" Android: layout_width="Fill_parent"
  4. Android: layout_height="Fill_parent">
  5. <Textview Android: layout_width="Fill_parent"
  6. Android: layout_height="Wrap_content" Android: Text="@ String/hello"
  7. Style="@ Style/textview" />
  8. <Edittext Android: ID="@ + ID/edittext01" Android: layout_height="Wrap_content"
  9. Style="@ Style/edittext" Android: layout_width="Fill_parent"
  10. Android: Text="Edittext similar to button"></Edittext>
  11. <Edittext Android: ID="@ + ID/edittext02" Android: layout_height="Wrap_content"
  12. Android: layout_width="Fill_parent" Android: Text="Normal edittext"></Edittext>
  13. <Button Android: ID="@ + ID/button01" Android: layout_height="Wrap_content"
  14. Style="@ Style/button" Android: layout_width="Fill_parent" Android: Text="Button similar to edittext"></Button>
  15. </Linearlayout>

<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Orientation = "vertical" Android: layout_width = "fill_parent" <br/> Android: layout_height = "fill_parent"> <br/> <textview Android: layout_width = "fill_parent" <br/> Android: layout_height = "wrap_content" Android: TEXT = "@ string/Hello" <br/> style = "@ style/textview"/> <br/> <edittext Android: id = "@ + ID/edittext01" Android: layout_height = "wrap_content" <br/> style = "@ style/edittext" Android: layout_width = "fill_parent" <br/> Android: text = "edittext similar to a button"> </edittext> <br/> <edittext Android: id = "@ + ID/edittext02" Android: layout_height = "wrap_content" <br/> Android: layout_width = "fill_parent" Android: TEXT = "normal edittext"> </edittext> <br/> <button Android: Id = "@ + ID/button01" Android: layout_height = "wrap_content" <br/> style = "@ style/button" Android: layout_width = "fill_parent" Android: TEXT = "button similar to edittext"> </button> <br/> </linearlayout> <br/>

 

Share:

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.