Shape Drawable :
An XML file that defines a geometric shape.Including colors and gradients. Creats a ShapeDrawable.
1.以shape为根元素需要两个元素:xmlns:android="http://schemas.android.com/apk/res/android" (必要)和 形状(rectangle,oval,line,ring)
子元素包括:
<corners>
- android:radius="integer"
- android:topLeftRadius="integer"
- android:topRightRadius="integer"
- android:bottomLeftRadius="integer"
- android:bottomRightRadius="integer"
<gradient>
- android:angle="integer" 设置渐变的角度,数值必须为45的倍数,默认为0,即从左到右渐变。当值为90时,从下到上渐变,以此类推当值为180时
- 为270时从上向下渐变。
- android:centerX="integer" 渐变的水平中心点,值为0-1.0
- android:centerY="integer" 渐变的垂直中心点,值为0-1.0
- android:centerColor="integer" 中心的颜色,非必须
- android:endColor="color" 结束渐变时的颜色
- android:gradientRadius="integer" 渐变的半径,仅适用于android:type="radial"时
- android:startColor="color" 开始渐变时的颜色
- android:type=["linear" | "radial" | "sweep"] 渐变的类型,分别为线状、中心放射状、经测试类似于雷达扫描的一种形态(词汇匮乏不知道该怎么翻译,⊙﹏⊙b汗)
- android:usesLevel=["true" | "false"] 貌似是可以被当做level-list用的意思
<padding>
是为内容或子标签设置边距
<size>
设置背景大小,width和height俩属性
<solid>
设置颜色,如果设置了gradient则这项无效
<stroke>
描边
android:width="integer"
android:color="color"
android:dashwidth="integer" and android:dashgap="integer" 当是虚线时使用。一个是虚线的长度,一个是虚线的间距