Geeks With Blogs
Bill Osuch - Random geek notes

In a previous post I showed how to create a custom multi-line ListView bound to an ArrayList. Let’s make it a little more visually appealing and give each item some rounded corners.

If you followed the previous how-to you wound up with something that looked like this:


To put each ListView item (name, address & phone) into its own rounded-corner box, create a new file in your res/drawable directory called border.xml, and paste in the following code:

<shape xmlns:android="" >
    <stroke android:width="1dp" android:color="#FFFFFF" />
    <padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp" />
    <corners android:radius="8dp" />

Then, specify the background of your LinearLayout in custom_row_view.xml:


And that’s it:


Of course, you can mess with colors, padding etc. to get the look you want, and you can apply this to just about any object in your layout.

Technorati Tags:

Posted on Monday, February 6, 2012 4:26 PM Android | Back to top

Comments on this post: Android–Create a ListView with rounded corners

# re: Android–Create a ListView with rounded corners
Requesting Gravatar...
i applied your code in my prog but round corner is on full listview not in particular item. pls help me...
Left by megha on Apr 10, 2013 6:40 AM

# re: Android–Create a ListView with rounded corners
Requesting Gravatar...
Put this code android:background="@drawable/border" in adapter layout background as shown below

android:background="@drawable/round_shape" />
Left by Punithapriya on Oct 06, 2015 11:49 PM

Your comment:
 (will show your gravatar)

Copyright © Bill Osuch | Powered by: