1.在drawable 中创建一个文件 ;
<?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="#4cffffff"
android:dashGap="5dp"
android:dashWidth="5dp" />
</shape>
2.在xml中使用
<View
android:id="@+id/dotted_line"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_marginLeft="13dp"
android:layout_marginRight="13dp"
android:background="@drawable/bg_dotted_line"
android:layerType="software"
/>
注意一定要添加layerType