Loading...

How to Add Ripple Effect/Animation to a Android Button

In this tips, I’m going to show you to implement ripple effect/animation in your android buttons. Now, you can easily add ripple effect/animation in your buttons, layouts, textviews, etc. and you can also change its color. Note that, this ripple effect/animation will only show on device running lollipop and above.

Related:
Android Elevation Example
How to Change Android Button on Click/Press Color
News List XML UI Design with Image

Here, I have mentioned two method to implement ripple effect in your android button and you can apply in view and view group by the same way.

Ripple Effect Example

Method 1:  To Add Ripple Effect/Animation to a Android Button

Just replace your button background attribute with android:background="?attr/selectableItemBackground" and your code looks like this.


Method 2:  To Add Ripple Effect/Animation to a Android Button

Using this method, you can customize ripple effect color. First, you have to create a xml file in your drawable resource directory. Create a ripple_effect.xml file and add following code.
res/drawable/ripple_effect.xml

And set background of button to above drawable resource file. Final code of xml layout activity looks like this.
res/layout/ button_ripple_effect.xml

XML 9195576336221643078
Home item