1.虚线圆角矩形框(上图中的代码):
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 矩形框的大小,上面rectangle为矩形-->
<size android:height="220dp"
android:width="345dp"/>
<!-- 中间的填充颜色为透明-->
<solid android:color="#0000"/>
<!-- 圆角大小为3dp-->
<corners android:radius="3dp"/>
<!-- 描边 dashWidth和dashGap属性,只要其中一个设置为0dp,则边框为实现边框
dashWidth每一个虚线的大小,dashGap虚线之间的间距
color虚线颜色,width虚线宽度-->
<stroke android:dashWidth="10dp"
android:dashGap="3dp"
android:color="#FFDDDDDD"
android:width="1dp"/>
</shape>
2.下面为详细解释
<!-- 圆角 -->
<corners
android:radius="9dp" <!-- 设置四个角的圆角半径 -->
android:topLeftRadius="2dp" <!-- 设置左上圆角半径 -->
android:topRightRadius="2dp" <!-- 设置右上圆角半径 -->
android:bottomLeftRadius="2dp" <!-- 设置坐下圆角半径 -->
android:bottomRightRadius="2dp"/> <!-- 设置右下圆角半径 -->
<!-- 渐变 -->
<gradient
android:startColor="开始颜色"
android:centerColor="中间"
android:endColor="结束颜色"
android:useLevel="false" <!-- 必须为false -->
android:angle="45"
android:type="radial"
android:centerX="0"
android:centerY="0"
android:gradientRadius="90"/>
<!-- 间隔 -->
<padding
android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp"/>
<!-- 大小 -->
<size
android:width="50dp"
android:height="50dp"/>
<!-- 填充 -->
<solid
android:color="@android:color/white"/><!-- 填充的颜色 -->
<!-- 描边 -->
<stroke
android:width="2dp"
android:color="@android:color/black"
android:dashWidth="1dp"
android:dashGap="2dp"/>
更多好内容戳下面:
https://blog.csdn.net/wuqingsen1