Android ListView With Rounded Corners

To make a ListView with rounded corners make a new xml file which will handle the rounded corners. “roundedlistview.xml”

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <gradient android:startColor="#ffffff" android:endColor="#000000" 
            android:angle="270"/> 

    <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" 
     android:topLeftRadius="7dp" android:topRightRadius="7dp"/> 
</shape> 

Now to call this you can do this by code or through xml.

listView.setBackgroundResource(R.drawable.roundedlistview);
android:background="@drawable/roundedlistview"
Posted in Android, Tips and Tricks Tagged with: , ,