Reputation: 4103
I have a problem that I want to create a list view with rounded corners but I failed to achieve the same. Please suggest me for the right solution.
CustomShape XML:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<stroke android:width="1dp" android:color="#ffbbbbbb" />
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp"
/>
</shape>
</item>
<item android:top="1dp" android:left="1dp" android:right="1dp" android:bottom="1dp">
<shape >
<solid android:color="#ffffffff" />
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp"
/>
</shape>
</item>
</layer-list>
main XML:
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginRight="10dp"
android:layout_marginBottom="10dp" android:layout_marginTop="120dip">
<ListView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/lv_homeScreen" android:cacheColorHint="@color/WHITE" android:dividerHeight="0dp" android:background="@drawable/customshape">
</ListView>
</LinearLayout>
I have attached the code which I am using for the same desire. Please have a look and share me if there are any flaws.
Thanks in advance.
Upvotes: 3
Views: 1399
Reputation: 56
set this container.xml (in drawable) as the background of your listview:
<gradient
android:startColor="#FFF"
android:centerColor="#FFF"
android:endColor="#FFFF"
android:angle="270"/>
<stroke
android:width="2dp"
android:color="#e98d59"/>
<corners
android:radius="10dp"/>
Upvotes: 4