<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape=["rectangle" | "oval" | "line" | "ring"] //shape形状,默认矩形,可以设置为矩形|椭圆形|线性形状|环形
//下面的属性只有在android:shape="ring"时可用:
android:innerRadius="10dp" //内环的半径;
android:innerRadiusRatio="2" //浮点型,以环的宽度比率来表示内环的半径;
android:thickness="3dp" //环的厚度;
android:thicknessRatio="2" //浮点型,以环的宽度比率来表示环的厚度;
android:useLevel="false" > //boolean值,如果当做是LevelListDrawable使用时值为true,否则为false。
<corners //圆角属性
android:radius="integer" //全部的圆角半径
android:topLeftRadius="integer" //左上角的圆角半径
android:topRightRadius="integer" //右上角的圆角半径
android:bottomLeftRadius="integer" //左下角的圆角半径
android:bottomRightRadius="integer" /> //右下角的圆角半径
<gradient //渐变属性
android:angle="integer" //渐变角度,必须为45的倍数,0为从左到右,90为从上到下
android:centerX="integer" //渐变中心X的相当位置,范围为0~1
android:centerY="integer" //渐变中心Y的相当位置,范围为0~1
android:startColor="color" //渐变开始点的颜色
android:centerColor="integer" //渐变中间点的颜色,在开始与结束点之间
android:endColor="color" //渐变结束点的颜色
android:gradientRadius="integer" //渐变的半径,只有当渐变类型为radial时才能使用
android:type=["linear" | "radial" | "sweep"] //共有3中渐变类型,线性渐变(默认)/放射渐变/扫描式渐变
android:useLevel=["true" | "false"] /> //使用LevelListDrawable时就要设置为true。设为false时才有渐变效果
<padding //边距属性
android:left="integer" //左内边距
android:top="integer" //上内边距
android:right="integer" //右内边距
android:bottom="integer" /> //下内边距
<size //大小属性
android:width="integer" //宽度
android:height="integer" /> //高度
<solid //填充属性
android:color="color" /> //内部填充色
<stroke //描边属性
android:width="integer" //描边的宽度
android:color="color" //描边的颜色
// 以下两个属性设置虚线
android:dashWidth="integer" //虚线的宽度,值为0时是实线
android:dashGap="integer" /> //虚线的间隔
</shape>
Android--shape属性
最新推荐文章于 2022-10-01 12:48:14 发布