Summary from here: How to create a ListView with rounded corners in Android? (I found this very useful.)
Add the following to the file (say gradient.xml) and then put it in the directory (res / drawable / gradient.xml).
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#SomeGradientBeginColor" android:endColor="#SomeGradientEndColor" android:angle="270"/> <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp"/> </shape>
Once you are done creating this file, just set the background in one of the following ways:
Via code: listView.setBackgroundResource(R.drawable.customshape);
Via XML, simply add the following attribute to the container (for example: LinearLayout or any fields):
android:background="@drawable/customshape"
user274294 Jul 15 '14 at 2:21 2014-07-15 02:21
source share