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="http://schemas.android.com/apk/res/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" />
</shape>
Then, specify the background of your LinearLayout in custom_row_view.xml:
android:background="@drawable/border"
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: Android