SHAPE has five attributes.
1. Solid indicates the solid color
Solid Android: color = "#000000" NOTE: This parameter can be left empty when used in combination with gradient.
2. Gradient indicates the gradient color
Android: startcolor = "#000000" start color
Android: centercolor = "# ff8c00" color in the middle
Android: endcolor = "# ffffff" End color
Android: angle = "45" gradient start angle. For example, 0 indicates a vertical gradient, and 90 indicates a horizontal gradient.
Android: uselevel = "true". Why?-1
Android: TYPE = "RADIAL" Gradient Pattern linear radial sweep
Note: When Android: TYPE = "RADIAL", you must set the Android: gradientradius gradient radius.
Android: gradientradius: the radius of the gradient is better to be larger, and the effect is obvious.
Android: relative position (0-0.5) of X in the gradient center of centerx = "1.0 ). Invalid when Android: TYPE = "linear"
Android: relative position of X in the gradient center of centery = "0.5" (0-1.0 ). Invalid when Android: TYPE = "linear"
3. Stroke indicates the border
Android: width = "1dp" Border Width
Android: color = "# dcdcdc" border color
Android: dashwidth = "5dp" dotted line length
Android: dashgap = "5dp" indicates the distance between the dotted lines.
4. Corners indicates the rounded corner.
Android: toprightradius = "5dp" upper right corner
Android: bottomleftradius = "5dp" bottom right corner
Android: topleftradius = "5dp" upper left corner
Android: bottomrightradius = "5dp" lower left corner
Android: radius = "5dp" indicates that the angle of the four corners is 5.
5. Padding indicates the row spacing
Write a simple XML
<? XML version = "1.0" encoding = "UTF-8"?> <Shape xmlns: Android = "http://schemas.android.com/apk/res/android"> <! -- Solid --> <solid Android: color = "# ff9d77"/> <! -- Gradient --> <gradient Android: endcolor = "# ffffff" Android: startcolor = "#000000" Android: TYPE = "RADIAL" Android: gradientradius = "100" Android: centerx = "0.5" Android: centery = "0.5" Android: angle = "90"/> <! -- Stroke --> <stroke Android: width = "2dp" Android: color = "# dcdcdc" Android: dashgap = "2dp" Android: dashwidth = "5dp"/> <! -- Rounded corner --> <corners Android: radius = "2dp"/> <padding Android: Bottom = "50dp" Android: Left = "50dp" Android: Right = "50dp" Android: top = "50dp"/> </shape>
Effect:
Mobile development QQ group: 59516399