虚线的分割线
shape画虚线
shape_imaginary_line.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
<stroke android:color="@color/colorBlack" android:width="1dp" android:dashWidth="2dp" android:dashGap="2dp"/>
</shape>
不加这个android:shape="line">
,样式就会是下面这样,一个虚线的框
在View中使用
imaginary_line.xml
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/shape_imaginary_line"
android:layerType="software"/>
在布局中使用
<include layout="@layout/imaginary_line"/>