|  
 Android新手开发之旅目录
 
 
  
 首先在res/drawable下新建文件,例如bg_dashed.xml:
 
 [XML] 纯文本查看 复制代码 <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
    <stroke
        android:width="0.5dp"
        android:color="#ccc"
        android:dashGap="3dp"
        android:dashWidth="6dp" />
</shape>
 然后设置为view的background:
 
 [XML] 纯文本查看 复制代码 <View
                android:layout_width="match_parent"
                android:layout_height="2dp"
                android:layout_marginBottom="5dp"
                android:layout_marginTop="10dp"
                android:background="@drawable/bg_dashed"
                android:layerType="software" />
 这样就实现了一条虚线
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 |