<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring"> <!-- rectangle | line | oval | ring 默认为rectangle--> <!-- The radius is used when dang shape="rectangle", which will be overridden by the default 1dp by the following single radius attribute--> <corners android:bottomLeftRadius="integer" android:bottomRightRadius="integer" android:radius="integer" android:topLeftRadius="integer" android:topRightRadius="integer" /> <gradient android:angle="integer" android:centerColor="integer" android:centerX="integer" android:centerY="integer" android:endColor="color" android:gradientRadius="integer" android:startColor="color" android:type="linear" android:useLevel="false" /> <padding android:bottom="integer" android:left="integer" android:right="integer" android:top="integer" /> <!--Specify the size, generally used in imageview with scaleType attribute --> <size android:width="integer" android:height="integer" /> <!-- fill color--> <solid android:color="color" /> <stroke android:width="integer" android:color="color" android:dashGap="integer" android:dashWidth="integer" /> <!-- dash width Width between dotted lines --> </shape>
Come up with an example
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!-- rectangle | line | oval | ring The default is rectangle--> <!-- The radius is used when dang shape="rectangle", which will be overridden by the default 1dp by the following single radius attribute--> <gradient android:angle="45" android:endColor="#805FBBFF" android:startColor="#FF5DA2FF" /> <padding android:bottom="7dp" android:left="7dp" android:right="7dp" android:top="7dp" /> <corners android:radius="8dp" /> </shape>