The Android custom control style is in the XML file in the drawable folder. In the layout file, you can set the control's background attribute to achieve the effect. I. Common states of controls: selector nodes are used in XML files. selector can be understood as a state switch. Different styles are switched under different states, and various States are represented by Item nodes, the following are some common states (Note: The first item in statelist that matches the current state will be used. Therefore, if the first item does not have any State feature, it will be used every time, which is why the default value must always be at the end and can be used in different States ): 1. android: state_pressedboolean. "True" indicates that the press is used (for example, when a button is pressed), and "false" indicates that the press is not used. 2. android: state_focusedboolean. "True" indicates that the focus state is used (for example, the scroll ball/d-pad is used to focus the button); "false" indicates that the focus state is used. 3. android: state_selectedboolean. "True" indicates that the selected state is used (for example, the tab is opened); "false" indicates that the selected state is used. 4. android: state_checkableboolean. "True" indicates that the status can be checked; "false" indicates that the status is not checked. (It is only useful for components that can be switched and checked-uncheckable .) 5. android: state_checkedboolean. "True" indicates that the selected status is used; "false" indicates that the selected status is not used. 6. android: state_enabledboolean. "True" indicates the available status (can receive touch/click events); "false" indicates the unavailable status. 7. android: window_focusedboolean. "True" indicates that the application window is used when there is focus (the application is on the foreground); "false" indicates that the focus is used when there is no focus (for example, the notification bar is pulled down or displayed in the dialog box ). 2. shape attributes: each State (item) corresponds to an effect. shape is used to define the shape. The following are some common attributes of shape: 1. solid: solid, android: color specifies the fill color 2. gradient: gradient android: startColor and android: endColor respectively indicate the start and end colors. android: angle indicates the gradient angle, it must be an integer multiple of 45. When angle is 0, the gradient is from left to right. Then it turns counter-clockwise. When angle is 90, it goes from bottom to top. In addition, the default gradient mode is android: type = "linear", that is, linear gradient. You can specify the gradient as a radial gradient, android: type = "radial", and the radius must be specified for the radial gradient android: gradientRadius = "50", you can also specify the combination of the two, scan the gradient android: type = "sweep" 3, stroke: stroke android: width = "2dp" stroke width, android: color stroke color. We can also set the stroke to a dotted line in the form of android: dashWidth = "5dp" android: dashGap = "3dp" Where android: dashWidth indicates the width of a horizontal line like '-', and android: dashGap indicates the distance between them. 4. corners: rounded corner android: radius is the Radian of an angle. The larger the value is, the closer the angle is. We can also set the four angles to different angles by android: topRightRadius = "20dp": android: bottomLeftRadius = "20dp": android: topLeftRadius = "1dp" top left corner android: bottomRightRadius = "0dp" bottom left corner here you need to note that bottomLeftRadius is the bottom right corner, not the bottom left corner 5, panding: the complete definition of a Button is as follows: <? Xml version = "1.0" encoding = "UTF-8"?> <Selector xmlns: android = "http://schemas.android.com/apk/res/android"> <item android: state_pressed = "true"> <shape> <gradient android: angle = "270" android: endColor = "# FFFFFF" android: startColor = "# ff8c00"/> <stroke android: width = "2dp" android: color = "# dcdcdc"/> <corners android: radius = "2dp"/> <padding android: bottom = "10dp" android: left = "10dp" android: right = "10dp" android: top = "10dp"/> </shape> </item> <item android: state_focused = "true"> <shape> <gradient android: angle = "270" android: endColor = "# ffc2b7" android: startColor = "# ffc2b7"/> <stroke android: width = "2dp" android: color = "# dcdcdc"/> <corners android: radius = "2dp"/> www.2cto.com <padding android: bottom = "10dp" android: left = "10dp" android: right = "10dp" android: top = "10dp"/> </shape> </item> <shape> <gradient android: angle = "270" android: endColor = "# ff9d77" android: startColor = "# ff9d77"/> <stroke android: width = "2dp" android: color = "# fad3cf"/> <corners android: radius = "2dp"/> <padding android: bottom = "10dp" android: left = "10dp" android: right = "10dp" android: top = "10dp"/> </shape> </item> </selector>