title: In Android how do you use a selector on a ListView to change the background color that will allow the text to appear as well?
body: <p>I'm currently using an android:listSelector in order to change the color of the background of a selected item in my list.  This works well, but when the color changes, you can no longer read the text that was displaying for that list item.  What am I doing wrong?  How can I get the selected item in my list to change color while not covering the text for that item?</p>
  
  <p>What I want is for the background color to change from gray to orange (when it is selected) like it is currently doing, but I would also like for my text to display during the color change to orange.</p>
  
  <p>This is my activity_main.xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/gray_lines" &gt;
  
      &lt;ImageView
          android:id="@+id/header"
          android:layout_width="wrap_content"
          android:layout_height="45dp"
          android:scaleType="fitXY"
          android:src="@drawable/logo_header" /&gt;
  
      &lt;!-- Footer aligned to bottom --&gt;
      &lt;ImageView
          android:id="@+id/footer"
          android:layout_width="match_parent"
          android:layout_height="30dp"
          android:layout_alignParentBottom="true"
          android:scaleType="fitXY"
          android:src="@drawable/orange" /&gt;
  
      &lt;TextView
          android:id="@+id/footerText"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_marginBottom="5dp"
          android:layout_marginLeft="14dp"
          android:onClick="contactPressed"
          android:text="@string/footerText" /&gt;
  
      &lt;ListView
          android:id="@+id/mainMenuList"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@id/header"
          android:layout_above="@id/footer"
          android:listSelector="@drawable/item"
          android:drawSelectorOnTop="true"
          android:divider="#000000"
          android:dividerHeight="0.1dp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>This is my list_item.xml which is used to populate the contents of each item in the listView.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/gray" &gt;
  
      &lt;ImageView
          android:id="@+id/img"
          android:layout_width="30dp"
          android:layout_height="30dp"
          android:layout_marginRight="15dp"
          android:layout_marginTop="20dp"
          android:layout_alignParentRight="true" /&gt;
  
      &lt;TextView
          android:id="@+id/txt"
          android:layout_width="wrap_content"
          android:layout_height="50dp"
          android:layout_marginTop="17dp"
          android:layout_marginLeft="15dp"
          android:textSize="23sp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and this finally is my selector xml (labeled item.xml)</p>
  
  <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item android:state_enabled="false" android:state_focused="true"
          android:drawable="@drawable/orange" /&gt;
    &lt;item android:state_pressed="true"
          android:drawable="@drawable/orange" /&gt;
    &lt;item android:state_focused="true"
          android:drawable="@drawable/orange" /&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>Thanks!</p>