<?xml version="1.0" encoding="utf-8"?> <!-- solid:实心 stroke:描边 dashWidth 虚线一个破折号的宽度,dashGap表示之间隔开的距离。 corners:圆角 android:radius为角的弧度,值越大角越圆。 --> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#FF0000FF" /> <stroke android:width="4dp" android:color="#FFFFFFFF" android:dashWidth="1dp" android:dashGap="2dp" /> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp" /> <corners android:radius="4dp" /> </shape>
<?xml version="1.0" encoding="utf-8"?> <!-- gradient:渐变 startColor和endColor分别为起始和结束颜色, ndroid:angle是渐变角度,必须为45的整数倍。 另外渐变默认的模式为android:type="linear",即线性渐变,可以指定渐变为径向渐变, android:type="radial",径向渐变需要指定半径android:gradientRadius="50"。 corners:圆角 可以通过四个属性设置对应的角度: topRightRadius,bottomLeftRadius, topLeftRadius,bottomRightRadius --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" android:angle="270" /> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp" /> <corners android:radius="8dp" /> </shape>