I am using a linear layout and setting a drawable xml as background. This background should change on user click. This is the code and the drawable xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/user_row_layout"
android:background="@drawable/row_background"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/user_row_textlayout"
android:background="@drawable/row_background"
android:layout_weight="0.5"
android:orientation="vertical"
android:layout_gravity="left"
android:padding="5dp"
android:paddingLeft="10dip" >
<TextView
android:id="@+id/displayName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textColor="@drawable/tab_text_selector"
android:textStyle="bold" />
<TextView
android:id="@+id/user_speciality_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/displayName"
android:textColor="@drawable/tab_text_selector" />
</RelativeLayout>
<ImageView
android:id="@+id/call_image_button"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:src="@drawable/user_list_call_button"
android:contentDescription="@string/call_contact" />
</LinearLayout>
Here is row_background
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/my_green" />
<item android:state_focused="true" android:drawable="@color/my_green" />
<item android:state_selected="true" android:drawable="@color/my_green" />
<item android:drawable="@color/white" />
</selector>
However, if I put the same "@drawable/row_background" inside just on element (ex:Relative Layout), it works like a charm. But I want the background to change for the entire row. The background doesnt change even for the relative layout part when I put it outside. Is there something obvious I missed? Also the images I use are transparent images. Thank you for your time.