水平虚线
<?xml version="1.0" encoding="utf-8"?>
<shape
android:shape="line"
xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:dashWidth="2dp"
android:dashGap="2dp"
android:color="@color/dash"
android:width="1dp"
/>
</shape>
竖直虚线:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-300dp"
android:right="-300dp"
>
<rotate
android:drawable="@drawable/horizontal_dash"
android:fromDegrees="90"
android:visible="true"/>
</item>
</layer-list>
View:
<View
android:id="@+id/top_dash"
android:layout_width="1dp"
android:layout_height="0dp"
android:layout_weight="1"
android:layerType="software"
android:background="@drawable/vertical_dash"/>
注意:竖直虚线时View的高度要大于虚线设定的宽度,否则显示不出来。