Selector:
<?XML version= "1.0" encoding= "Utf-8"?><selectorxmlns:android= "Http://schemas.android.com/apk/res/android"><!--background picture by default - <Itemandroid:drawable= "@drawable/pic1" /><!--background picture When there is no focus - <Itemandroid:state_window_focused= "false"android:drawable= "@drawable/pic1" /><!--background picture When you get focus in non-touch mode and click - <Itemandroid:state_focused= "true"android:state_pressed= "true"android:drawable= "@drawable/pic2" /><!--background picture when clicked in touch mode - <Itemandroid:state_focused= "false"android:state_pressed= "true"android:drawable= "@drawable/pic3" /><!--picture Background When selected - <Itemandroid:state_selected= "true"android:drawable= "@drawable/pic4" /><!--picture background when getting focus - <Itemandroid:state_focused= "true"android:drawable= "@drawable/pic5" /></selector>
Related properties: android:state_selected is selected android:state_focused is gaining focus android:state_pressed is click android:state_enabled is the set response event, which refers to all events------------------------------------------------------------------------------------------Shape:
<?XML version= "1.0" encoding= "Utf-8"?><Shapexmlns:android= "Http://schemas.android.com/apk/res/android" > <!--Rounded Corners - <CornersAndroid:radius= "9DP"Android:topleftradius= "2DP"Android:toprightradius= "2DP"Android:bottomleftradius= "2DP"Android:bottomrightradius= "2DP"/><!--set the fillet radius - <!--Gradient - <GradientAndroid:startcolor= "@android: Color/white"Android:centercolor= "@android: Color/black"Android:endcolor= "@android: Color/black"Android:uselevel= "true"Android:angle= "$"Android:type= "Radial"Android:centerx= "0"Android:centery= "0"Android:gradientradius= "All"/> <!--interval - <paddingAndroid:left= "2DP"Android:top= "2DP"Android:right= "2DP"Android:bottom= "2DP"/><!--intervals in each direction - <!--size - <sizeAndroid:width= "50DP"Android:height= "50DP"/><!--Width and Height - <!--Fill - <SolidAndroid:color= "@android: Color/white"/><!--the color of the fill - <!--Strokes - <StrokeAndroid:width= "2DP"Android:color= "@android: Color/black"Android:dashwidth= "1DP"Android:dashgap= "2DP"/> </Shape>
Solid: solid, meaning of fill
ANDROID:COLOR Specifies the color of the fill
Gradient: Gradient
Android:startcolor and Android:endcolor are start and end colors respectively, Ndroid:angle is the gradient angle and must be an integer multiple of 45.
In addition, the default mode of the gradient is android:type= "linear", that is, linear gradient, you can specify the gradient to radial gradient, android:type= "radial", radial gradient needs to specify the radius android:gradientradius= "50".
Stroke: Stroke
Android:width= the width of the "2DP" stroke, android:color the color of the stroke.
We can also make the stroke into a dashed form, set in the following way:
Android:dashwidth= "5DP"
android:dashgap= "3DP"
Where android:dashwidth represents the width of a horizontal line such as '-', android:dashgap represents the distance between them.
Corners: Rounded Corners
The Android:radius is the radian of the angle, and the larger the value the greater the rounded.
We can also set the four angles to different angles by:
<corners
android:toprightradius= "20DP" upper right corner
android:bottomleftradius= "20DP" lower right corner
android:topleftradius= "1DP" upper left corner
android:bottomrightradius= "0DP" lower left corner
/>
Here is a place to pay attention, Bottomleftradius is the lower right corner, not the lower left corner, this is a bit depressed, but do not affect the use, remember not to make a mistake on the line.
padding: Interval
Android selector (background selector), shape (set shape)