shape可以是圆形,矩形
solid 填充
android:color指定填充的颜色
gradient: 渐变
startColor centerColor endColor 起始中间和结束的颜色
angle 渐变角度 必须是45度的整数倍
type 渐变模式
linear: 线性渐变
radial :径向渐变,需指定半径
stroke 描边
width: 宽度
color: 颜色
dashWidth: 表示一个横线的宽度
dashGap: 表示之间隔开的距离
corners 圆角
radius 角的弧度
android:topLeftRadius="20dp" 设置左上角的半径
android:topRightRadius="20dp" 设置右上角的半径
android:bottomLeftRadius="20dp" 设置右下角的半径
android:bottomRightRadius="20dp" 设置左下角的半径
padding: 间隔
以下是一个没有左右边框的矩形,带边线.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@color/white" />
</shape>
</item>
<item
android:bottom="1dip"
android:top="1dip">
<shape>
<solid android:color="@color/white" />
</shape>
</item>
</layer-list>