I added selectableItemBackground to the CardView, which is displayed in recyclerview mode. Each CardView displays text and image. each card can be selected, and to add a ripple effect when pressed, I added:
android:background="?attr/selectableItemBackground"
The problem is that now I can not set the background color. these two lines together indicate an error:
android:background="?attr/selectableItemBackground"
android:background="#FFFFFF"
How can I color the layout background and also add a ripple effect using selectableItemBackground.
full code card_view.xml:
<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">
<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 cannot paint the background color white by combining the attr / selectableItemBackground effect for the ripple effect, and then it looks like this:
