shape资源
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:dashGap="5dp"
android:dashWidth="8dp"
android:width="1dp"
android:color="#70ffffff" />
<!-- 虚线的高度 -->
<size android:height="1dp" />
</shape>
layout文件设置background即可:
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layerType="software"
android:background="@drawable/line_dash" />
有的设备会显示为实线