

In my apps, I like to offer users the preference of choosing a light or dark color scheme as they desire. So our file ( listview_selector.The default Android ListView object is difficult to work with if creativity is one of your design factors.

To specify when to apply the shape we use the status. In this case we use the XML tag selector to specify when and how to apply the shape. To do it we have to create another XML file that describe how we apply this shape. Once we have create our shape we need to apply it to the items. solid – solid colour that fills the shape.stroke – a stroke line for the shape (witdh, color, dashWidth and dashGap).A shape is a geometrical figure that is described by other tags: Let’s call this file rounded_corners.xml. We need to create a file XML under the res/drawable directory. background color (in our case a solid color).

We have to specify some information to create this figure: As you may already know this is powerful feature of Android because it permits us to create geometrical figure in XML style. In this post we don’t want to spend too much words about adapters because we described them here and here.Īs we said the first thing we need is a drawable resource. As you already know we have to create a custom adapter to implement this behaviour. How can we do this?…We need to create some drawable resources and apply them to each item. Let’s suppose we want to create rounded corner for each item. In the second example we will show how we can alternate the background color. The first example will describe how we can create rounded corners for each item inside a listview. In this post we want to describe how we can use resource to customize the item look. By now we considered just custom adapter without taking into account how we can customize how each item inside the listview appears. We can customize the look of the ListView in the way we like, for example with can use as background rounded corner, alternate color and so on. One aspect we didn’t consider in the previous posts is how we can apply style or background to the Listview items (or row).
