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:
- Theme is for the form level and changes the form style;
- 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
?
-
- <! -- 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>
<! -- 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
?
-
- <?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>
<? 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: