Android Studio xmls shape properties

xmls shape properties

属性表:

属性 属性值 描述
shape --------- ----------
dither true/false 将在位图的像素配置与屏幕不同是启用为(ARGB8000位图和RGB565屏幕)启用位图抖动,值为false停止
shape rectangle/line/oval/ring 分别为矩形,线,椭圆,环默认为rectangle
innerRadius integer shape为ring时可用,内环半径
innerRadiusRatio float shape为ring时可用内环的厚度比,即环的比表示内环半径,默认为3可被innerRadius值覆盖
thickness integer shape为ring时可用,环的厚度
thicknessRatio float 环的厚度比即环的宽度比 表示环的厚度,默认为9,可被thickness值覆盖
tint color 给shape着色
tintMode src_in / src_atop / stc_over / add / multiply / screen 着色类型
visible false / true 设置可见性
corners ----------- ------圆角-----
radius integer 半径,如果设置该属性则以下几个属性失效
bottomLeftRadius integer 左下角圆角半径
bottomRightRadius integer 右下角圆角半径
topLeftRadius integer 左上角圆角半径
topRightRadius integer 右上角圆角半径
gradient ----------- ------渐变-----
useLevenl false/true 与上面shape的属性是否一致
type linear / radial / sweep 渐变类型,分别为线性,放射性,扫描性渐变默认渐变性
angle integer 渐变角度,当上面type为线性渐变linear时有效。角度为45的倍数
centerColor color 渐变中间位置的颜色
startColor color 渐变开始位置的颜色
endColor color 渐变结束位置的颜色
centerX float type为放射性radial时有效,设置渐变中心X的坐标,取值区域为【0,1】默认为0.5
centerY float type为放射性radial时有效,设置渐变中心Y的坐标,取值区域为【0,1】默认为0.5
gradientRadius integer type为放射性渐变radial时有效,渐变半径
size --------- ----大小—
width integer 宽度
height integer 高度
solid --------- ------填充------
color color shape填充的颜色
stroke --------- -----描边-----
color color 描边的颜色
width integer 描边的宽度
dashGap integer 虚线间隔
dashWidth integer 虚线宽度
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:innerRadius="50dp"
    android:innerRadiusRatio="5"
    android:thickness="120dp"
    android:thicknessRatio="8"
    android:useLevel="false"
    >
    <gradient
        android:type="linear"
        android:useLevel="false"
        android:angle="45"
        android:startColor="@color/colorAccent"
        android:centerColor="@android:color/black"
        android:endColor="@color/colorPrimary"/>
</shape>

Android Studio xmls shape properties