1、在drawble下面自定义资源文件 dashline
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <stroke android:dashGap="3px" android:dashWidth="2px" android:width="1dip" android:color="@color/white_true" /> <!-- 虚线的高度 --> <size android:height="2px" /> </shape>
2、布局中引用
height一定要足够高,不仅要不dashline的高度高~~~否则不显示
<View android:id="@+id/v_dashLine" android:layout_width="match_parent" android:layout_height="10px" android:layout_alignParentBottom="true" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:background="@drawable/dashline" />
<activity android:name=".Activity" android:hardwareAccelerated="false" android:launchMode="singleTop" android:screenOrientation="portrait"/>
hardwareAccelerated="false" 若不加,则5.0以上版本显示为实线