If you're not satisfied with the UI controls that come with your Android system, you can try a custom control, and we'll take the button as an example, a long time ago Android123 wrote the Android button button control beautification method that mentions the selector constructs of XML. Of course, in addition to using images like Drawable, the Android web today talks about customizing the shape shapes, and supports the following properties on the button control Android shape, gradient, stroke, corners, and so on.
Copy Code code as follows:
Let's take the current system button selector as an example:
< android:startcolor= "#ff8c00"
Android:endcolor= "#FFFFFF"
android:angle= "270"/>
< android:width= "2DP"
Android:color= "#dcdcdc"/>
< android:radius= "2DP"/>
< android:left= "10DP"
android:top= "10DP"
android:right= "10DP"
android:bottom= "10DP"/>
For the above, the definition of this shape, respectively, is a gradient, in gradient the StartColor property is the beginning of the color, endcolor for the gradient end of the color, the following angle is the angle. Next is stroke can be understood as the edge, corners for the corner here Radius property is radius, and finally relative position attribute padding.
For a button The complete definition can be thought
Copy Code code as follows:
<xmlns:android= "Http://schemas.android.com/apk/res/Android" >
<android:startcolor= "#ff8c00"
Android:endcolor= "#FFFFFF"
android:angle= "270"/>
<android:width= "2DP"
Android:color= "#dcdcdc"/>
<android:radius= "2DP"/>
<android:left= "10DP"
android:top= "10DP"
android:right= "10DP"
android:bottom= "10DP"/>
<android:startcolor= "#ffc2b7"
Android:endcolor= "#ffc2b7"
android:angle= "270"/>
<android:width= "2DP"
Android:color= "#dcdcdc"/>
<android:radius= "2DP"/>
<android:left= "10DP"
android:top= "10DP"
android:right= "10DP"
android:bottom= "10DP"/>
<android:startcolor= "#ff9d77"
Android:endcolor= "#ff9d77"
android:angle= "270"/>
<android:width= "2DP"
Android:color= "#fad3cf"/>
<android:radius= "2DP"/>
<android:left= "10DP"
android:top= "10DP"
android:right= "10DP"
android:bottom= "10DP"/>
Tip, the difference between the above several item is mainly reflected in state_pressed press or state_focused gain focus, when to determine what type of display, and no state_xxx attributes of the item can be seen as normal state.