In view of the current Internet development, more and more Internet enterprises have deployed their clients on the Android platform, and in order to enhance the user experience, these clients have made the layout reasonable and beautiful. The Android style design introduced in this article is one of the keys to improving the user experience. The style on Android is divided into two areas:
1.Theme is for the form level, changing the form style;
The 2.Style is for the form element level, changing the specified control or layout style.
The Android Themes.xml and Style.xml (located in/base/core/res/res/values/) contain a number of system-defined style, suggesting that you pick the right one and then inherit the changes. The following code attributes are more common in themes, originating from the Android system itself Themes.xml:
<!--window attributes--> <item name= "Windowbackground" > @android:d rawable /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:d rawable/title_bar_ shadow</item> <item name= "Windowtitlestyle" > @android:style/windowtitle</item> <item " Windowtitlesize ">25dip</item> <item name=" Windowtitlebackgroundstyle "> @android: style/ windowtitlebackground</item> <item name= "Android:windowanimationstyle" > @android: style/ Animation.activity</item>
As for the control's style design is much broader, look at the Eclipse's Android control property editor [properties] to know what the entries are, and the Android built-in Style.xml just defines the default style for each control. However, the control style does not recommend a big change, engaging style allows users to use the software for a long time. In addition, the control's style in many cases use 9.png, learning 9.png must go to the/base/core/res/res/drawable-hdpi inside look, there are many systems built in 9.png.
Note: In order to study the Android style and theme, it is highly recommended to download the Android base.git!
Let's take a look at the effect of this procedure, as shown in the following illustration:
The Themes.xml code for this procedure is as follows, customizing the WindowTitle:
<?xml version= "1.0" encoding= "UTF-8"?>
<resources>
<!--inherits the Android built in Theme.light, located in/base/ Core/res/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 the activity, either use the Code settheme (r.style.theme), or set the following in application manifest:
The Styles.xml code for this procedure is as follows, background the default is to use 9.png,xml defined under/base/core/res/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 "Android: Shadowradius ">2.0</item> </style> <style name=" EditText "> <item name=" Android:shadowcolor "& gt; @android:color/black</item> <item name= "Android:shadowradius" >1.0</item> <item name= " Android:background "> @android:d rawable/btn_default</item> <item name=" Android:textappearance "? android:attr/textappearancemedium</item> </style> <style name= "button" > <item name= "android:b" Ackground "> @android:d rawable/edit_text</item> <item name=" Android:textappearance ">?android:attr/ textappearancemedium</item> </style> </resources>
The
Main.xml code is as follows:
<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout "xmlns:android=" 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= " Button-like EditText "></EditText> <edittext android:id=" @+id/edittext02 "android:layout_height=" Wrap_ Content "Android:layout_width=" fill_parent "android:text=" Ordinary EditText "></EditText> <button android:id= "@+id/button01" android:layout_height= "wrap_content" style= "@style/button" android:layout_width= "Fill_parent" android:text= "button with similar edittext" ></Button> </LinearLayout>