Android Custom Listview Tutorial - Part 2

Moving ahead from first part Custom List view,  we are going to discuss three things.

1.Adding background colors to Listview

2.Adding different Divider color.

3.Triggering action on listview click.

Step 1:

Listview Background Color

Adding Custom Background color to listview . For an elegance look for an application the listview color play a key role.

[sourcecode language="java"]

convertView.setBackgroundColor((position & 1) == 1 ? Color.WHITE : Color.LTGRAY);


Android Layout Background Image

Now we are going to see about android layout background image. Also you can check our previous post about the android layout background color.

In android, we can set a image to layout as background by using background property in layout.

Android Layout Background Color

In android, we can set the layout background color using background property in layout.
Example for Layout Background Color :-
[sourcecode language="xml"]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:background="#0000ff" />
The output will looks like

Android Button Background Color

Android Button Background Color Example -

We can set the button background color by using the button property 'android:background' .

Android Textview Background Color

Here we are going to see an example for setting the Android textview background color...

[sourcecode language="css"]

<TextView android:background="#ff23cf"


By using the android:background="#ff23cf" piece of code the textview background will be filled with #ff23cf color.<

Android Text Color

In Android, we can set text color for textview, edittext, buttons, etc...




Syndicate content