Android: Custom ListView Design


For designing a custom ListView you might face following design bugs.

Background Of ListView:

To adjust the background color of our ListView according to our design theme we will use android:background attribute of ListView. Note that we can put any color or background image or any drawable object or animation.

Color Hint (Faded Upper and Bottom Limit of ListView):

To adjust the Faded Upper and Bottom Limit of our ListView according to our design theme we will use android:cacheColorHint attribute of ListView.

Divider (Thin Line at Bottom of each List Item):

This is awfully irritating but good we have solution for it. To adjust Thin Line at Bottom of each List Item of our ListView according to our design theme we will use android:divider attribute of ListView.

Layout Width:

If you don’t adjust android:layout_width of ListView to match_parent the empty free area of parent will be filled by default color, it is not must but we cannot exclude the posibility.

So, finally our sample ListView code will be:

<ListView android:layout_height="wrap_content" 
		android:layout_width="match_parent" 
		android:id="@+id/mylist" 
		android:background="#FFFFFF" 
		android:cacheColorHint="#FFFFFF" 
		android:divider="#FFFFFF">
</ListView>