在Android中使用shape画虚线,一定要加上
android:layerType="software"这句话,不然显示的就是直线
画虚线的
beijing_xuxian_black.xml文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1.5dp"
android:color="@color/black_bantouming_25"
android:dashGap="4dp"
android:dashWidth="5dp" />
</shape>
布局文件中使用
<View
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_marginLeft="11dp"
android:layout_marginRight="11dp"
android:background="@drawable/beijing_xuxian_black"
android:layerType="software" />