How to Implement Ripple Effect in Android

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

How to Implement Ripple Effect/Animation in Android

Here, I have mentioned two different methods to implement ripple animation in your android application.

How to Add Ripple Effect/Animation to a Android Button
Android Floating Labels for EditText Using Design Support Library
Relative Layout - Views Position in Android

Method 1 - To Implement Ripple Effect/Animation in Android

To implement effect on press/click just add android:background="?attr/selectableItemBackground" or android:background="?attr/selectableItemBackgroundBorderless" in android View or ViewGroup as background.

Method 2: To Implement Ripple Effect/Animation in Android

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

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

XML 1094659171841805017
Home item