Shape for the setting of shapes, can be used in selector,layout and so on, click on the effect of God horse we can not need the UI of the transduction, their direct use of shape, more convenient and quick. Create a new shape.xml default is a rectangle, you can set the specific shape by android:shape= "", there are four kinds: rectangle rectangle, Oval oval, line, Ring ring. Shape has 6 sub-tags, each with the following properties:
<?xml version= "1.0" encoding= "Utf-8"? ><shape xmlns:android= "Http://schemas.android.com/apk/res/android" Android:shape= "Rectangle" > <!--rounded Corners--<corners android:bottomleftradius= "8dip" android:b ottomrightradius= "8dip" android:radius= "5dip" android:topleftradius= "8dip" android:toprightradius= "8d IP "/> <!--color Gradient-<gradient android:angle=" android:centercolor= "@android: Color/blac K "android:endcolor=" @android: Color/black "android:startcolor=" @android: Color/white "Android:type=" Li Near "/> <!--size and <size android:height=" 28dip "android:width=" 48dip "/> <!-- Stroke--<stroke android:dashgap= "2DP" android:dashwidth= "1DP" android:width= "1dip" an Droid:color= "@color/red"/> <!--margin-<padding android:bottom= "5dip" android:left= "5dip" android:right= "5dip" android:top= "3dip"/> <!--filled-in <solid android:color= "@color/slateblue"/></shape>
Fill:set the color of the fill
interval: sets the interval in four directions
Size: set Size
fillet: set five properties at the same time, the RADIUS attribute is invalid
android:radius= "20DP" sets the radius of Four Corners
android:topleftradius= "20DP" sets the radius of the upper-left corner
Android:toprightradius= "20DP" set the radius of the upper-right corner
android:bottomleftradius= "20DP" setting the radius of the lower right corner
Android:bottomrightradius= "20DP" set the radius of the lower left corner
strokes:dashwidth and Dashgap properties, as long as one is set to 0DP, the border is the implementation border
android:width=" 20DP " set the edge width
android:color= @android: color/black Set the color of edges;
Android: Dashwidth= "2DP" set the width of the dashed line
android:dashgap= "20DP" set the interval width for dashes
Gradients: when the fill color is set, there is no gradient effect. The value of the angle must be a multiple of 45 (including 0), only valid in type= "linear", or it will be an error. Android:uselevel This attribute does not know what is the use.
Basic use of shape in Android