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.

有帮助吗?

解决方案

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"

其他提示

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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top