Please give me code adding vertical dotted lines in a list view.I have tried using creating an xml using shape tag method
Asked
Active
Viewed 4,493 times
-3
-
2People will help you if you request **help** not `Code`. Post whatever you tried so far. – Monish Kamble Dec 10 '16 at 16:39
-
1http://stackoverflow.com/questions/6103713/how-do-i-make-a-dotted-dashed-line-in-android – Tiago Oliveira Dec 10 '16 at 16:45
2 Answers
7
Try using below code.
horizontal_dashed_line.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#ff0000"
android:dashWidth="4dp"
android:dashGap="4dp"/>
</shape>
vertical_dashed_line.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:toDegrees="90"
android:drawable="@drawable/horizontal_dashed_line"/>
Usage:
<View
android:layout_width="4dp"
android:layout_height="300dp"
android:background="@drawable/horizontal_dashed_line"/>
Checkout below article for more details.
How to create vertical or horizontal dashed lines with Android drawables

Priyank Patel
- 12,244
- 8
- 65
- 85
0
UPDATE
InCase the above verticle.xml not worked TRY this one. AS this Worked for me.
vertical_dashed_line.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-600dp"
android:right="-600dp">
<rotate
android:drawable="@drawable/horizontal_dashed_line"
android:fromDegrees="90"
android:visible="true" />
</item>
</layer-list>

Ammar
- 765
- 1
- 8
- 18
-
in case dotted not visible to your phone use `android:layerType="software"` in **
– Ammar Aug 16 '21 at 13:34