效果图:
1.在drawable建立dash_line虚线样式:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke android:dashWidth="5dp"
android:dashGap="3dp"
android:color="@color/app_line"
android:width="0.5dp"/>
</shape>
2.xml布局直接使用:
<View
android:layerType="software"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/dash_line" />
注意:layerType(试过不加此属性,结果不显示虚线)和layout_height(试过加了属性,0.5dp太小,结果也不显示),不然会显示不出来滴!!!
补充:
发现了个大神将这个讲解得十分详细:
Android样式的开发:shape篇 - 安卓 - 伯乐在线 http://android.jobbole.com/82108/