- 0
- 0
- 约5.04千字
- 约 14页
- 2020-08-23 发布于天津
- 举报
androidshape 使用总结电脑资料
今天使用到 shape,这个里面有很多属性,在这里我记录一下各
个属性的使用的情况以及所代表的意思
复制代码
xmlns:android=schemas.android./apk/res/android
android:shape=[rectangle | oval | line | ring]
android:radius=integer
android:topLeftRadius=integer
android:topRightRadius=integer
android:bottomLeftRadius=integer
android:bottomRightRadius=integer /
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] /
android:left=integer
android:top=integer
android:right=integer
android:bottom=integer /
android:width=integer
android:height=integer /
android:color=color /
android:width=integer
android:color=color
android:dashWidth=integer
android:dashGap=integer /
复制代码
上面这段就是 shape 使用的格式,来看一下如何使用:
定义这是一个 GradientDrawable ,必须作为根元素,
android:shape
定义 shape 的值,必须是下面的之一:
rectangle 矩阵,这也是默认的 shape
oval 椭圆
line 一条水平的直线。这种 shape 必须使用 元素来定义这条
线的宽度
ring 圆环
下面的属性只有当 android:shape=ring 才使用:
android:innerRadius
尺寸。 内环的半径。一个尺寸值 (dip 等等)或者一个尺寸资源。
android:innerRadiusRatio
Float 类型。这个值表示内部环的比例,例如 , 如果
android:innerRadiusRatio = 5 , 那么内部的半径等于环的宽度
除以 5。这个值会被 android:innerRadius 重写。 默认值是 9 。
android:thickness
尺寸。环的厚度,是一个尺寸值或尺寸的资源。
android:thicknessRatio
Float 类型。厚度的比例。 例如 , 如果 android:thicknessRatio=
2 , 然后厚度等于环的宽度除以 2。这个值是被 android:innerRadius
重写, 默认值是 3 。
android:useLevel
Boolean 类型。如果用在 LevelListDrawable 里,那么就是 true 。
如果通常不出现则为 false 。
为 Shape 创建一个圆角,只有 shape 是 rectangle 时候才使用。
原创力文档

文档评论(0)