Create shape for drawable

4.2k views Asked by At

I have ListView, and i have a background for the list items:

List item background image

Is there any way to recreate this background as a shape in drawable XML? The most outer grey is not part of the item background, it is actually the ListView.

2

There are 2 answers

0
Ritesh Gune On BEST ANSWER

You can try following with the values of your choice. It will make the bottom two corners rounded.

rounded_rectangle.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">   
    <item>
    <shape>
        <gradient android:angle="270" android:endColor="#404040"              android:startColor="#404040" />
        <stroke android:width="1dp" android:color="#808080" />
        <corners android:bottomLeftRadius="11dp" android:bottomRightRadius="11dp"/>
    </shape>
    </item>
</selector>

then use it as a background to your listitem as follows

android:background="@drawable/rounded_rectangle"
1
Marc Tan On

You can try this shape drawable:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#606060"/>
    <stroke android:color="#303030" android:width="2dp" />
</shape>