我成功地找到了如何创建一个自定义形状(带有虚线边框)的方法,需要在 /app/res/drawable/ 文件夹中创建名为 dash.xml 的文件:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#534b4b"
android:width="1dp"
android:dashGap="2dp"
android:dashWidth="1dp"
/>
<size
android:height="1dp"
/>
</shape>
现在我不知道如何将这个形状应用到ListView上。我尝试了以下方法,但没有显示分隔线:
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:divider="@drawable/dash"
android:dividerHeight="1dp"
/>
什么鬼?