Question

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.

Était-ce utile?

La solution

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"

Autres conseils

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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top