<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<!-- android:shape="rectangle"矩形line线性 oval椭圆 ring圆 -->
<solid android:color="@color/button_selected" />
<!-- 实心填充颜色 -->
<gradient
android:angle="90"
android:endColor="#0000ff"
android:gradientRadius="50"
android:startColor="#ff0000"
android:type="radial" />
<!-- 渐变 -->
<!-- android:startColor="#ff0000" 开始颜色 -->
<!-- android:endColor="#0000ff" 结束颜色 -->
<!-- android:angle="90" 渐变角度 45的倍数 -->
<!-- android:type="linear" 渐变模式 linear 线性 radial半径 sweep -->
<!-- android:gradientRadius="50"渐变半径 如果模式为半径则必须指定渐变半径 -->
<!-- android:centerX Float。渐变色中心的X相对位置(0-1.0)。当android:type="linear"时无效。 -->
<!-- android:centerY Float。渐变色中心的Y相对位置(0-1.0)。当android:type="linear"时无效。 -->
<!-- android:centerColor Color。可选的颜色,出现在start和end颜色之间。 -->
<stroke
android:dashGap="2dip"
android:dashWidth="5dip"
android:width="10dip"
android:color="#ff00ff" />
<!-- 描边 -->
<!-- android:width="10"边线宽度 -->
<!-- android:color="#ff00ff"边线颜色 -->
<!-- android:dashWidth="10dip"虚线宽度 -->
<!-- android:dashGap="10dip"间隔宽度 -->
<corners
android:bottomLeftRadius="8.0dip"
android:bottomRightRadius="8.0dip"
android:radius="8dip"
android:topLeftRadius="8.0dip"
android:topRightRadius="8.0dip" />
<!-- 圆角 -->
<!-- android:radius="8dip"值越大 弧度越大 -->
<!-- android:topLeftRadius="8.0dip" 左上 -->
<!-- android:topRightRadius="8.0dip" 右上 -->
<!-- android:bottomLeftRadius="8.0dip" 右下 -->
<!-- android:bottomRightRadius="8.0dip" 左下 -->
<padding
android:bottom="10dip"
android:left="10dip"
android:right="10dip"
android:top="10dip" />
<!-- 间隔 -->
<!-- android:shape="ring"时使用: -->
<!-- android:innerRadius Dimension。内环的半径。 -->
<!-- android:innerRadiusRatio Float。以环的宽度比率来表示内环的半径。例如,如果android:innerRadiusRatio="5",内环半径等于环的宽度除以5。这个值可以被android:innerRadius覆盖。默认值是9。 -->
<!-- android:thickness Dimension。环的厚度。 -->
<!-- android:thicknessRatio Float。以环的宽度比率来表示环的厚度。例如,如果android:thicknessRatio="2",厚度就等于环的宽度除以2。这个值可以被android:thickness覆盖。默认值是3。 -->
<!-- android:useLevel Boolean。"true"表示可以当作LevelListDrawable使用。一般都为"false"。 -->
<!-- 画圆useLevel不能少 -->
</shape>
使用line虚线是需要设置关闭硬件加速
在Manifest的Activity里面设置
android:hardwareAccelerated="false"
或者
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
使用时可添加到background中
版权声明:本文为博主原创文章,未经博主允许不得转载。