title: CardView's background which will respond to android:state_selected and android:state_pressed
body: <p>I'm referring to the answer at <a href="https://stackoverflow.com/a/24475228/72437">https://stackoverflow.com/a/24475228/72437</a></p>
  
  <p>The proposed answer is using drawable from Android : <code>?android:attr/selectableItemBackground</code></p>
  
  <p><a href="https://i.stack.imgur.com/hZHzy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hZHzy.png" alt="enter image description here"></a></p>
  
  <p>This is what happen when I tap on the card item. Note that, by using drawable from Android, <code>android:state_selected="true"</code> (when <code>setSelected(true)</code>) will not have any color change effect.</p>
  
  <p>Hence, I would like to use my own defined drawable so that</p>
  
  <ol>
  <li>It looks nicer.</li>
  <li>Able to handle <code>android:state_selected="true"</code>.</li>
  </ol>
  
  <p>Here's my code</p>
  
  <hr>
  
  <h2>statelist_item_background.xml</h2>
  
  <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" android:drawable="@drawable/selected_background" /&gt;
      &lt;item android:state_selected="true" android:drawable="@drawable/selected_background" /&gt;
      &lt;item android:drawable="@android:color/transparent" /&gt;
  
  &lt;/selector&gt;
  </code></pre>
  
  <h2>selected_background.xml</h2>
  
  <pre><code>&lt;shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;solid android:color="#ffffe1b3" /&gt;
      &lt;stroke
          android:width="1px"
          android:color="#fff76d3c" /&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <h2>card_row.xml</h2>
  
  <pre><code>&lt;!-- A CardView that contains a TextView --&gt;
  &lt;android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:card_view="http://schemas.android.com/apk/res-auto"
      android:id="@+id/card_view"
      android:layout_marginLeft="5dp"
      android:layout_marginRight="5dp"
      android:layout_marginTop="5dp"
      android:layout_marginBottom="5dp"
      android:clickable="true"
      android:foreground="@drawable/statelist_item_background"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;LinearLayout
          android:padding="5dp"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
          &lt;TextView
              android:id="@+id/txt_label_item"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textAppearance="?android:attr/textAppearanceLarge"
              tools:text="Item Number One" /&gt;
  
          &lt;TextView
              android:id="@+id/txt_date_time"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textAppearance="?android:attr/textAppearanceMedium"
              tools:text="Item Number One" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/android.support.v7.widget.CardView&gt;
  </code></pre>
  
  <p>When I long press on the card item and perform <code>childView.setSelected(true);</code>, here's my outcome.</p>
  
  <p><a href="https://i.stack.imgur.com/DCk9y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DCk9y.png" alt="enter image description here"></a></p>
  
  <p>All my card content (<code>TextView</code>s) are blocked. How can I avoid such?</p>
  
  <h2>Some notes regarding using android:background</h2>
  
  <p>Note, when you use <code>android:background="@drawable/statelist_item_background"</code> with <code>CardView</code> itself, nothing will happen.</p>
  
  <p>However, if you use <code>android:background="@drawable/statelist_item_background"</code> with <code>CardView</code>'s <code>LinearLayout</code>, <strong>you will get the following imperfect outcome</strong>.</p>
  
  <p><a href="https://i.stack.imgur.com/SLcHs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SLcHs.png" alt="enter image description here"></a></p>
  
  <p><strong>The highlighted color doesn't cover the entire card</strong>.</p>
  
  <h2>Update</h2>
  
  <p>Seem like this is limitation of <code>CardView</code> - <a href="https://code.google.com/p/android/issues/detail?id=78198" rel="nofollow noreferrer">https://code.google.com/p/android/issues/detail?id=78198</a> Using "foreground" as workaround is not an option as it covers card content.</p>