<shape>形状
|
属性 |
含义 |
类型 |
取值 |
备注 |
|
android:shape |
形状 |
枚举 |
rectagle矩形|正方形,oval椭圆|正圆, line水平直线,ring环形 |
画line时,用<stroke>定义线的高度 |
|
android:innerRadius |
内半径 |
尺寸 |
|
android:shape="ring"y有效 |
|
android:thickness |
环厚度 |
尺寸 |
|
|
|
android:innerRadiusRatio |
内半径比例 |
数字 |
|
|
|
android:thicknessRatio |
环厚度比例 |
数字 |
|
|
|
android:useLevel |
|
布尔 |
false |
举例:
|
|
|
|
|
<shape
|
<shape android:shape= "rectangle"/>
|
<shape android:shape= "oval"/>
|
<shape android:shape= "line">
<stroke android:width=
"10dp"
</shape> |
<size>大小
|
属性 |
含义 |
类型 |
取值 |
备注 |
|
android:width |
长度 |
尺寸 |
|
|
|
android:height |
高度 |
尺寸 |
|
|
<padding>内边距
|
属性 |
含义 |
类型 |
取值 |
备注 |
|
android:left |
左边距 |
尺寸 |
|
|
|
android:top |
上边距 |
尺寸 |
|
|
|
android:right |
右边距 |
尺寸 |
|
|
|
android:bottom |
下边距 |
尺寸 |
|
|
<corners>圆角
|
属性 |
含义 |
类型 |
取值 |
备注 |
|
android:radius |
四角的弧度 |
尺寸 |
设置0dp,无圆角 设置>1dp, 有圆角 值越大角越圆 |
只适用于rectagle |
|
android:topRightRadius |
右上角弧度 |
尺寸 |
||
|
android:bottomLeftRadius |
右下角弧度 |
尺寸 |
||
|
android:topLeftRadius |
左上角弧度 |
尺寸 |
||
|
android:bottomRightRadius |
左下角弧度 |
尺寸 |
举例:
|
|
|
<shape android:shape= "rectangle"> <corners android:radius= "30dp"/> <solid android:color= "#fa1621"/> </shape> |
<shape android:shape= "rectangle" > <corners android:bottomLeftRadius= "20dp" android:bottomRightRadius= "0dp" android:topLeftRadius= "0dp" android:topRightRadius= "20dp" /> </shape> |
<stroke> 描边
|
属性 |
含义 |
类型 |
取值 |
备注 |
|
android:width |
描边的宽度 |
尺寸 |
|
|
|
android:color |
描边的颜色 |
颜色 |
|
|
|
android:dashWidth |
边框分段长度 |
尺寸 |
|
2属性要同时设置 |
|
android:dashGap |
边框分段间隙 |
尺寸 |
|
举例:
|
|
|
<stroke android:width= "10dp" android:color= "#fa1621" />
|
<stroke android:width= "10dp" android:color= "#fa1621" android:dashWidth= "10dp" android:dashGap= "5dp" />
|
<solid>填充
|
属性 |
含义 |
类型 |
取值 |
备注 |
|
android:color |
填充的颜色 |
颜色 |
|
|
<gradient> 渐变颜色
|
属性 |
含义 |
类型 |
取值 |
备注 |
|
android:startColor |
渐变开始颜色 |
颜色 |
|
|
|
android:centerColor |
渐变中间颜色 |
颜色 |
|
|
|
android:endColor |
渐变结束颜色 |
颜色 |
|
|
|
android:angle |
渐变角度 |
整字 |
0,默认值表示从左到右渐变90表示从下到上渐变,取值必须是45的倍数 |
|
|
android:centerX |
渐变中心相对于x轴位置 |
小数 |
0-1.0 |
|
|
android:centerY |
渐变中心相对于y轴位置 |
小数 |
0-1.0 |
|
|
android:type |
渐变的样式 |
枚举 |
linear线性渐变radial环形渐变sweep |
|
|
android:gradientRadius |
渐变半径 |
小数 |
|
android:type="radial"必填 |
|
android:useLevel |
|
布尔 |
true用于LevelListDrawable |
|
举例:
|
|
|
|
<gradient android:endColor= "#fa1621" android:startColor= "#f793ac" android:type= "linear"/> |
<gradient android:endColor= "#fa1621" android:startColor= "#f793ac" android:type= "radial" android:gradientRadius= "50"/> |
<gradient android:endColor= "#fa1621" android:startColor= "#f793ac" android:type= "sweep"/> |
|
|
|
|
<gradient android:endColor= "#fa1621" android:startColor= "#f793ac" android:type= "linear" android:angle= "90"/> |
<gradient android:endColor= "#fa1621" android:startColor= "#f793ac" android:type= "radial" android:gradientRadius= "100" android:centerX= "0.5" android:centerY= "0"/> |
|
浙公网安备 33010602011771号