在我的布局中,我试图绘制一条虚线。为了绘制一条水平线,我正在我的布局文件中定义一个视图。
     <View
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:background="@drawable/customdots" />
和 customdots.xml
 <?xml version="1.0" encoding="utf-8"?>
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
  <item
    android:left="10dp"
    android:right="10dp"
    android:width="4dp"
    android:drawable="@drawable/dotted" />
 </layer-list>
dotted.xml
  <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
  <size
    android:height="4dp"
    android:width="1024dp"/>
  <stroke
   android:width="4dp" 
   android:dashWidth="4dp"
   android:color="@android:color/black"
   android:dashGap="5dp"/>
</shape>
但我没有得到任何使用此代码的行。请帮帮我。
当我在 listView Divider 中使用 customdots.xml 作为
 android:divider="@drawable/customdots"
它显示了一条很好的虚线