문제

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