Question

So, I want to create an xml drawable that it will be a bakcground for an EditText. What I have now is an xml with three shapes (white, black and white) with corner Radius that create a black border.

What I want is to make this black border discontinous.

My actual code is:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item >
    <shape android:shape="rectangle">
        <solid android:color="@android:color/white"/>
        <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
    </shape>
</item>

<item android:bottom="5dp" android:top="5dp" android:left="5dp" android:right="5dp">
    <shape android:shape="rectangle">
        <solid android:color="@android:color/black"/>
        <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
    </shape>
</item>

<item android:bottom="8dp" android:top="8dp" android:left="8dp" android:right="8dp">
    <shape android:shape="rectangle">
        <solid android:color="@android:color/white"/>
        <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
    </shape>
</item>
</layer-list>
Was it helpful?

Solution

Try this:

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:bottom="5dp" android:top="5dp" android:left="5dp" android:right="5dp">
    <shape >
        <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
        <stroke android:color="@android:color/black"
                android:dashGap="10dp"
                android:dashWidth="10dp"
                android:width="1dip"/>
    </shape>
</item>

</layer-list>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top