I have added the selectableItemBackground on CardView that displays on recyclerview. each CardView show text and image. each Card is can be selected, and in order to add ripple effect when clicked I have added:
android:background="?attr/selectableItemBackground"
The problem is that now I cant set the background color. those two lines together show an error:
android:background="?attr/selectableItemBackground"
android:background="#FFFFFF"
How can I color the layout background and also add the ripple effect with selectableItemBackground.
complete card_view.xml code:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="2dp"
card_view:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:orientation="vertical">
<!--CANT ADD THIS: android:background="#FFFFFF"-->
<TextView
android:id="@+id/singleTextLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="3dp"
android:text="Test"
android:textSize="30dp" />
<ImageView
android:id="@+id/singleImage"
android:layout_width="fill_parent"
android:layout_height="125dp"
android:layout_gravity="center_horizontal"
android:layout_margin="3dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
The problem is that I can't color the background in white while combining the ?attr/selectableItemBackground for ripple effect and then it looks like this: