效果图:
Layout.xml布局中View设置background
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layerType="software"
android:background="@drawable/dash_line" />
dash_line.xml
中代码:
android:width
需要设置,否则不显示。
<?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="@color/divideLine"
android:dashWidth="3dp"
android:dashGap="2dp" />
<size android:height="1dp" />
</shape>