网上一搜一大把,但是最后自己可以用的还是相对难找,还是整理下以备不时之需:
<!--这里的layerType必须设置,否则会是实体线-->
<TextView
android:layerType="software"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@drawable/xuxian"></TextView>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<!--dashGap:虚线断点间的宽度;dashWidth:单个虚线段的宽度;width:虚线的高度-->
<!--这里有个需要注意的上面的width必须小于你在xml中给view指定的高度-->
<stroke
android:dashGap="2dp"
android:dashWidth="6dp"
android:width="1dp"
android:color="#e7e7e7" />
<!-- 虚线的高度 -->
<size android:height="1dp" /> >
</shape>