title: Apply gradient to rows in listview in android
body: <p>i've a list view with different colors depending on if it's an even or odd row:</p>
  
  <p>My custom adapter:</p>
  
  <pre><code> if ( position % 2 == 0)
          convertView.setBackgroundResource(R.layout.listview_selector_even);
        else
            convertView.setBackgroundResource(R.layout.listview_selector_odd);
  </code></pre>
  
  <p>list_selector_even:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;selector xmlns:android="http://schemas.android.com/apk/res/android" &gt;        
        &lt;item android:drawable="@layout/even_row" android:state_enabled="true"/&gt;
        &lt;item android:drawable="@layout/even_row" android:state_pressed="true"/&gt;
        &lt;item android:drawable="@layout/even_row" android:state_focused="true"/&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>list_selector_odd:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
     &lt;selector xmlns:android="http://schemas.android.com/apk/res/android" &gt; 
        &lt;item android:drawable="@layout/odd_row" android:state_enabled="true"/&gt;
        &lt;item android:drawable="@layout/odd_row" android:state_pressed="true"/&gt;
        &lt;item android:drawable="@layout/odd_row" android:state_focused="true"/&gt;
    &lt;/selector&gt;
  </code></pre>
  
  <p>even_row:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;solid android:color="#FFFFFF"/&gt;  
     &lt;padding android:left="3dp" android:top="3dp" android:right="3dp" android:bottom="3dp" /&gt;       
  &lt;/shape&gt;
  </code></pre>
  
  <p>odd_row:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;solid android:color="#F0F0F0"/&gt;
  &lt;padding android:left="3dp" android:top="3dp" android:right="3dp" android:bottom="3dp" /&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p>I'm a little bit lost because i cant get the even and odd rows colors working with the gradient effect. For the preessed effect gradient i've the next code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item android:state_pressed="true" &gt;
      &lt;shape&gt;
        &lt;gradient
          android:startColor="#3E5260"
          android:endColor="#3E5260"
          android:angle="270" /&gt;
      &lt;/shape&gt;
   &lt;/item&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>Thanks for the help!</p>