title: Change background and textcolor in cardview on touch
body: <p>I am having difficulty in changing the text color with the background color on touch (hover effect) in cardview. I have changed the background color but not the text color.</p>
  
  <p>I have also tried to use selector but i didn't worked out.</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_activated="true" android:drawable="@android:color/white" /&gt;
      &lt;item android:drawable="@android:color/black"/&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>It changes the color of the text and its background</p>
  
  <p><a href="https://i.stack.imgur.com/XEPsT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XEPsT.png" alt="enter image description here"></a></p>
  
  <p>My layout</p>
  
  <p><a href="https://i.stack.imgur.com/aBsLD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aBsLD.jpg" alt="enter image description here"></a></p>
  
  <p>on pressing I want to change the color text with the background </p>
  
  <p><a href="https://i.stack.imgur.com/cjoGd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cjoGd.png" alt="enter image description here"></a></p>
  
  <p>Here is my LayoutCode</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:card_view="http://schemas.android.com/apk/res-auto"
      android:id="@+id/main"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="#f1f1f3"
      android:orientation="vertical"&gt;
  
      &lt;android.support.v7.widget.CardView
          android:id="@+id/card_view"
          android:layout_width="fill_parent"
          android:layout_height="120dp"
          android:layout_gravity="center"
          android:layout_marginLeft="15dp"
          android:layout_marginRight="15dp"
          android:layout_marginTop="15dp"
          card_view:cardCornerRadius="0dp"
          card_view:contentPadding="0dp"&gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@drawable/listhover"&gt;
  
              &lt;ImageView
                  android:id="@+id/thumbnail"
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_alignParentLeft="true"
                  android:scaleType="fitXY"
                  android:src="@drawable/cardviewimage_cio" /&gt;
  
              &lt;TextView
                  android:id="@+id/textView"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentTop="true"
                  android:layout_marginLeft="12dp"
                  android:layout_marginTop="10dp"
                  android:layout_toEndOf="@+id/thumbnail"
                  android:textStyle="bold" /&gt;
  
              &lt;TextView
                  android:id="@+id/textView2"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignStart="@+id/textView"
                  android:layout_below="@+id/textView"
                  android:layout_marginTop="5dp"
                  android:textColor="#000" /&gt;
          &lt;/RelativeLayout&gt;
  
      &lt;/android.support.v7.widget.CardView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>