Dotted line in android [duplicate]

2019-06-05 06:47发布

问题:

This question already has an answer here:

  • Create a Horizontal dotted line in android layout 2 answers

I am working on android application in which I want to use dotted line xml as a divider in my layout. For this I have used different drawables but instead to make a dashed dotted line, it is making a line. My image is given below

回答1:

in your ListView put

android:divider="@drawable/dash"

And in drawable folder create dash.xml and put following code

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">
    <stroke
        android:color="#fdfdfd"
        android:width="1dp"
        android:dashGap="3dp"
        android:dashWidth="1dp"
        />
    <size
        android:height="3dp"
        />
</shape>

You can also change the color of dot