利用shape绘制虚线
真机调试时可能会出现虚线变实线的现象
在manifest文件对应的activity节点中设置
android:hardwareAccelerated="false"即可
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:width="1dp" android:color="#d3d3d3" android:dashWidth="10dp" android:dashGap="10dp" /> </shape>
width:线段的高度
color:线段的颜色
dashWidth:线段宽度
dashGap:线段之间间隔宽度