Setting the FloatingActionButton ripple

x10sion picture x10sion · Apr 14, 2016 · Viewed 14.8k times · Source

Im trying to set the FloatingActionButton ripple to something similar to this

From Material design.

The problem is that I only get a "Flat style" where there is no ripple, it just changes the button from, in my case, white to orange without the animation shown in the link above.

I have followed the answer here:

FloatingActionButton example with Support Library

but my FAB still is boring!

EDIT: My current code is: XML:

  <android.support.design.widget.FloatingActionButton
     android:id="@+id/item_activity_fab"
     android:layout_width="64dp"
     android:layout_height="64dp"
     android:layout_marginRight="16dp"
     android:src="@drawable/watch"
     app:borderWidth="0dp"
     app:elevation="6dp"
     app:fabSize="normal"
     app:layout_anchor="@id/item_activity_title_background"
     app:layout_anchorGravity="top|right|end"
     app:pressedTranslationZ="12dp"
     app:rippleColor="@android:color/transparent"/>

Java:

    mAddToWatchListFAB.setRippleColor(ContextCompat.getColor(this, R.color.orange_6));

I tried that method on the FAB but it didn't seem to work. I also tried the steps in the link I provided

Answer

Muhammad Usman picture Muhammad Usman · Jul 20, 2017

add following 2 properties to your floating action button xml code

 app:rippleColor="@color/textcolor"
 android:clickable="true"

making FAB clickable adds ripple color