Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 842
Mahozad Avatar asked Jan 10 '19 20:01

Mahozad


2 Answers

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>
like image 183
Martin Zeitler Avatar answered Sep 19 '22 11:09

Martin Zeitler


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

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

like image 38
Abdulmajeed Alyafei Avatar answered Sep 18 '22 11:09

Abdulmajeed Alyafei