If you are not satisfied with the UI control provided by the Android system, you can try the custom control. Let's take the Button as an example, android has previously written the Android Button control beautification method, which mentions the xml selector structure. Of course, in addition to using images such as drawable, the Android Development Network talked about the custom image shape method today. For the Button control Android, the following attributes are supported: shape, gradient, stroke, corners, etc.
Copy codeThe Code is as follows: Let's take the selector of the current system Button as an example:
<Android: startColor = "# ff8c00"
Android: endColor = "# FFFFFF"
Android: angle = "270" type = "parmname" text = "parmname"/>
<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 shape is defined as gradient. In gradient, the startColor attribute is the starting color, endColor is the color of the gradient, and the angle below is the angle. Next, stroke can be understood as the edge, corners is the corner. Here the radius attribute is the radius, and finally the relative position attribute padding.
The complete definition of a Button can beCopy codeThe Code is as follows:
<Xmlns: android = "http://schemas.android.com/apk/res/Android">
<Android: startColor = "# ff8c00"
Android: endColor = "# FFFFFF"
Android: angle = "270" type = "parmname" text = "parmname"/>
<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" type = "parmname" text = "parmname"/>
<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" type = "parmname" text = "parmname"/>
<Android: width = "2dp"
Android: color = "# fad3cf"/>
<Android: radius = "2dp"/>
<Android: left = "10dp"
Android: top = "10dp"
Android: right = "10dp"
Android: bottom = "10dp"/>
Note: The main difference between the preceding items is that when state_pressed is pressed or state_focused is used to obtain the focus, Dangdang determines the type of the item to be displayed. items without the state_xxx attribute can be considered as in the regular state.