原文:http://write.blog.csdn.net/postedit/50549154
例子:
<shapexmlns:android=http://schemas.android.com/apk/res/android
android:shape=["rectangle" | "oval" |"line" |"ring"]> --- 默认为rectangle
<corners--shape=“rectangle”时使用,
android:radius="integer"-- 半径,会被下边的属性覆盖,默认为1dp,
android:topLeftRadius="integer"
android:topRightRadius="integer"
android:bottomLeftRadius="integer"
android:bottomRightRadius="integer"/>
<gradient-- 渐变
android:angle="integer"
android:centerX="integer"
android:centerY="integer"
android:centerColor="integer"
android:endColor="color"
android:gradientRadius="integer"
android:startColor="color"
android:type=["linear" | "radial" |"sweep"]
android:useLevel=["true" | "false"]/>
<padding
android:left="integer"
android:top="integer"
android:right="integer"
android:bottom="integer"/>
<size-- 指定大小,一般用在imageview配合scaleType属性使用。大小一般会适配滴
android:width="integer"
android:height="integer"/>
<solid-- 填充颜色,可是是十六进制颜色。(比如想设置半透明效果,直接使用十六就只就OK)
android:color="color"/>
<stroke-- 指定边框,border,dashWidth和dashGap有一个为0dp则为
android:width="integer"
android:color="color"
android:dashWidth="integer"-- 虚线宽度
android:dashGap="integer"/> -- 虚线间隔宽度
</shape>
元素:
<shape>
-
android:shape中
rectangle 长方形, oval 椭圆形, line 线形, ring 环形
-
<corners> 圆角的弧度
-
android:radius 所有圆角的弧度
-
或设置
-
android:topLeftRadius
-
android:topRightRadius
-
android:bottomLeftRadius
-
android:bottomRightRadius
-
<gradient> 颜色渐变
-
android:angle 渐变的角度,它必须是45的倍数,默认值是0, 注意!!0度是在左边的中间,且逆时针 由小到大。
-
android:centerX android:centerY对渐变中心的相对位置
-
android:startColor起始颜色,一个十六进制的值或颜色资源。
-
android:endColor终止颜色
-
android:centerColor中间颜色
android:type 渐变的梯度模式
-
渐变默认的模式为android:type="linear",即线性渐变,
可以指定渐变为径向渐变,android:type="radial",径向渐变需要指定半径android:gradientRadius="50"。sweep扫线梯度(不确定)
-
android:useLeveltrue是作为一个levellistdrawable
-
<padding>间隔,可以设置上下左右四个方向的间隔,这个就不用过多解释了,很常用。android:left android:top android:right android:bottom
-
<size> 大小, android:height android:width
-
<solid> 填充颜色 android:color
-
<stroke> 描边
-
android:width边线的厚度
-
android:color边线颜色
-
android:dashGap虚线的小线“-”之间的距离
-
android:dashWidth虚线的“-”,一个横线的宽度
-
原文:http://write.blog.csdn.net/postedit/50549154
-
例子:(圆角空心边框矩形背景,边框2dp)
-
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android=http://schemas.android.com/apk/res/android
android:shape="rectangle" >
<!-- 填充的颜色 -->
<solid android:color="#FFFFFF" />
<!-- 设置矩形的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="7dip" />
<stroke android:width="2dp" /> -- 虚线间隔宽度
</shape>
-
-
-
-
-
-
-
-
-