1.在drawable里面写一个shape文件
破折线的宽度为dashWith,破折线之间的空隙的宽度为dashGap,当dashGap=0dp时,为实线
<?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="#000000"
android:dashWidth="3dp"
android:dashGap="2dp" />
<size android:height="1dp" />
</shape>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="100dp"
android:layout_marginRight="9dp"
android:background="@drawable/shape_line_stroke"
android:layerType="software" />
** ***注意一定要设置layerType,否则是一条直线**