通过repeat把一个图片重复拼接在一起成一条虚线
虚线资源文件repeat_bmp_h.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/repeat_h"
android:tileMode="repeat" >
</bitmap>
其中repeat_h是虚线其中的一小段图片,左右透明。程序中使用,只需要把repeat_bmp_h.xml设置为背景图片即可:
<View
android:id="@+id/v_curtaskitem_line"
android:layout_width="188dp"
android:layout_height="2dp"
android:layout_below="@id/tv_curtaskitem_time"
android:layout_marginTop="20dp"
android:layout_alignLeft="@id/tv_curtaskitem_time"
android:background="@drawable/repeat_bmp_h"/>
另,竖线的话,则把图片旋转90度即可得到竖的虚线