I managed to figure out how to create a custom shape (with a dashed stroke) by creating a file called dash.xml inside of the /app/res/drawable/ folder:
<?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>
Now I'm confused as to how to apply this shape to a ListView. I've tried the following, but no divider is displayed:
<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"
/>
Wtf?
Here is mine and it works :
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#FF404040"
android:width="1dp"
android:dashGap="3dp"
android:dashWidth="1dp"
/>
<size
android:height="3dp"
/>
</shape>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With