水平线背景
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:width="1dp" android:color="@color/colorAccent" android:dashGap="4dp" android:dashWidth="6dp"/> </shape>
竖直虚线
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:left="-600dp" android:right="-600dp"> ---》 让其居中显示 <rotate android:drawable="@drawable/line_stroke" android:visible="true" android:fromDegrees="90" /> </item> </layer-list>
引用
<TextView android:layout_width="80dp" android:layout_height="match_parent" android:layout_centerVertical="true" android:layerType="software" android:text="sss" android:background="@drawable/line_vertical" />