Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shape dashed line, dash doesn't work

I want to make dashed line using shape.

This is my XML:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="line">
            <stroke android:color="@color/grey_divider"
                android:width="1dip"
                android:dashWidth="5dip"
                android:dashGap="13dip"/>
        </shape>
    </item>
</selector>

On my device I see this: enter image description here But I need something like this:

enter image description here

How to fix it?

like image 676
Artem Avatar asked Dec 29 '16 11:12

Artem


1 Answers

Try this

Make one xml file in drawable.(e.g. dashed_line.xml)

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">

    <stroke
       android:color="#C7B299"
       android:dashWidth="10px"
       android:dashGap="10px"
       android:width="1dp"/>
</shape>

And now use this xml file in your layout.

android:background="@drawable/dashed_line"
like image 152
santosh kumar Avatar answered Nov 01 '22 03:11

santosh kumar