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.



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


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.
res/drawable/ripple_effect.xml


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


Comments

Popular posts from this blog

Minneapolis hiring social media influencers for former police officers’ trials

Best Navigation Drawer Libraries for Android Project

L’Oreal’s newest gadget takes the mess out of coloring your hair