效果展示:
先实现一个虚线框:
<!--在drawable中定义一个dashed_bg.xml-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:height="1dp"
android:color="#60B543"
android:dashWidth="2dp"
android:dashGap="2dp" />
<size
android:width="0.5dp"
android:height="100dp" />
</shape>
布局中使用背景:
<!--竖向虚线-->
<View
android:layout_width="2dp"
android:layout_height="13dp"
android:layout_centerInParent="true"
android:background="@drawable/dashed_bg" />
<!--横向虚线-->
<View
android:layout_width="match_parent"
android:layout_height="1.5dp"
android:layout_centerInParent="true"
android:background="@drawable/dashed_bg" />