IOS-style UIS are popular. Many Android UI designers are also willing to design Android UI into a UI style similar to IOS. The following is an example to illustrate how to use Shape to define an IOS-style button.
Define an ios_button_grouped.xml file.
<? Xmlversion = "1.0" encoding = "UTF-8"?>
<Selector
Xmlns: android = "http://schemas.android.com/apk/res/android">
<Item
Android: state_pressed = "true"
Android: drawable = "@ drawable/ios_button_grouped_pressed"/>
<Item
Android: state_focused = "true"
Android: state_window_focused = "true"
Android: drawable = "@ drawable/ios_button_grouped_pressed"/>
<Item
Android: drawable = "@ drawable/ios_button_grouped_normal"/>
</Selector>
Define ios_button_grouped_normal.xml
<? Xmlversion = "1.0" encoding = "UTF-8"?>
<Shape
Xmlns: android = "http://schemas.android.com/apk/res/android"
Android: shape = "rectangle">
<Solid
Android: color = "# eee"/>
<Stroke
Android: width = "1dp"
Android: color = "@ android: color/black"/>
<Corners
Android: radius = "5dp"/>
</Shape>
Define ios_button_grouped_pressed.xml
<? Xmlversion = "1.0" encoding = "UTF-8"?>
<Shape
Xmlns: android = "http://schemas.android.com/apk/res/android"
Android: shape = "rectangle">
<Solid
Android: color = "# 0be"/>
<Stroke
Android: width = "1dp"
Android: color = "@ android: color/black"/>
<Corners
Android: radius = "5dp"/>
</Shape>
Here we mainly define the color of the rectangle in the Shape. You can also set some color attributes, such as startColor, endColor, and angle, to define beautiful UI effects. We recommend that you refer to the API documentation.
Effect:
Usage:
Use the image as the background.
Android: background = "@ drawable/ios_button_grouped"
---------------------------------------------------------------------------
GL (arui319)
Http://blog.csdn.net/arui319
Excerpted from chinamoocs