首先,在drawab盟敢势袂le目录下写一个xml,名字随便起(只要符合规范), 代码如下
<?xmlversion="1.0"encoding="utf-8"?>
<shapexmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="270"
android:endColor="#000000"
android:startColor="#ffffff"/>
<corners
android:bottomLeftRadius="5dip"
android:bottomRightRadius="5dip"
android:topLeftRadius="5dip"
android:topRightRadius="5dip"/>
</shape>
shape 表示的是图形的形式,主要包括方形、圆形等,上边代码为方形,
gradient表示的主要配置起点颜色、终点颜色及中间点的颜色、坐标、渐变效果(0,90,180从左到右渐变,270从上到下渐变)默认从左到右padding表示的是主要配置上下左右的间距
corners 表示的是配置四周园脚的半径
然后,你在代码中或者xml布局中像图片一样使用它了。