'How to remove ripple effect from MaterialCardVew?

How can I disable touch ripple effect of MaterialCardView? Setting clickable attribute to false or playing with foreground and background attributes had no effect.

I'm using material support library version 1.1.0-alpha02.



Solution 1:[1]

Only the rippleColor is a styleable:

<com.google.android.material.card.MaterialCardView
    style="@style/Widget.MaterialComponents.CardView"
    app:rippleColor="@android:color/transparent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

</com.google.android.material.card.MaterialCardView>

Note: It doesn't remove the ripple effect from <androidx.cardview.widget.CardView though.

Solution 2:[2]

Just use this attribute in xml:
app:rippleColor="@android:color/transparent"

Or programatically in Kotlin:
cardView.rippleColor = ColorStateList.valueOf(Color.TRANSPARENT)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dr.jacky
Solution 2 Abdulmajeed Alyafei