画一条虚线,先再line_shape.xml中定义
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<!--线宽为dashWith,线之间空隙dashGap,dashGap=0dp时,是实线 -->
<stroke
android:width="1dp"
android:color="@android:color/holo_red_dark"
android:dashGap="7dp"
android:dashWidth="8dp" />
</shape>
在页面中引用
<View
android:id="@+id/import_recycler_item_line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/imaginary_line_shape"
android:layerType="software" />
需要注意的是 android:layerType=“software” ,如果不加是不显示的