在drawable文件夹下创建dash_line.xml文件
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
android:dashGap="5dp"
android:dashWidth="4dp"
android:width="1dp"
android:color="#CCCCCC"
/>
<!-- 虚线的高度 -->
<size android:height="0.5dp" />
</shape>
在页面的xml文件中调用如下:
<TextView
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@drawable/dash_line"
android:layerType="software"
></TextView>