Properties of shape:
Description: Internal padding
Properties: Android:color Fill Color
Description: Size
Property:
Android:width width
Android:height High
Description: Gradient Color
Property:
Android:startcolor Gradient Start Color
Android:endcolor Gradient End Color
Android:centercolor Gradient Middle Color
Android:angle the gradient angle, when angle=0, the gradient is left to right, then counterclockwise, and when angle=90, the gradient moves from the top down. Angle must be a multiple of 45.
Android:type Gradient Type: linear (linear), radial (radioactive, centered on start color), sweep (scanline gradient)
Android:userlevel set to True if you want to use the Levellistdrawable object. Set true no gradient color, false has gradient
Android:grdientradial gradient radius, this value only takes effect if the type is set to radial
Android:centerx the relative position of the X-point coordinates of the gradient center
Android:centery relative position of y-point coordinates of the gradient center
Description: Stroke
Property:
Android:width Stroke width
Android:color Stroke Color
Android:dashwidth stroke style is a dashed width, a value of 0 is solid, and a value greater than 0 is a dashed line
Android:dashgap the distance between dashes when the stroke is dashed
Description: Rounded Corners
Property:
Android:radius Four Corner radius value
Android:topleftradius the upper left corner radius value
Android:toprightradius the upper right corner radius value
Android:bottomleftradius the lower right corner radius value
Android:bottomrightradius lower left corner radius value
Description: Inner margin
Property:
Android:left left inner margin
Android:right right inner margin
Android:top on the inside margin
Android:bottom lower inner margin
Instance Code
<?xml version= "1.0" encoding= "Utf-8"?> <shape xmlns:android= "http://schemas.android.com/apk/res/ Android "> <corners android:radius=" 5DP "/> <size android:height=" 30DP " android:width = "20DP"/> <gradient android:startcolor= "#9933cc" android:endcolor= "#aa66cc" android: angle= " /> <padding android:left=" 5DP " android:right=" 5DP " android:top=" 5DP " android:bottom= "5DP"/> </shape>
<Button Android:id="@+id/btn"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:layout_below="@+id/tv_test"Android:background="@drawable/btn_shape"Android:text="Button"/>
Android Custom Shape Circle button