Loading...

Adding Ripple Effect/Animation on Android Image View

Everyone likes to implement ripple effect/animation in their application. In android 5.0 Lollipop and above device by default android has used ripple effect in buttons. If you want to set ripple effect/animation to any android views like layouts, text view, image view, etc you need to set manually yourself. In this tutorial, I am going to show how to set/add ripple effect/animation on android images.

There are two ways to set ripple effect in android either by creating custom XML file in drawable folder by using custom color value or using default attr value in background like background="?attr/selectableItemBackground" or background="?attr/selectableItemBackgroundBorderless".

Related:
How to Add Ripple Effect/Animation to a Android Button
Android Material Design with Design Support Library
How to Hide Android Status Bar Programmatically

Android Example: How to Set Ripple Effect/Animation on Android Images


To set custom ripple effect, first you have to create a new XML file in res/drawable folder. Following is the complete content of ripple_effect_android_image.xml file.

res/drawable/ ripple_effect_android_image.xml

XML Layout File

Here I have added an ImageView and a LinearLayout inside RelativeLayout to set ripple effect in android images. Following is the complete content of XML layout file.

res/ layout/ripple_effect_in_android_imageview_images.xml

Java Activity File

Default code of java activity file.

src/AndroidImageRippleAnimation.java

Android Example: How to Set Ripple Effect/Animation on Android Images

Now, run your Adding Ripple Effect/Animation on Android Image View application and click anywhere on the image, you will see the ripple effect with light red color which will look like above screenshot.
XML 5747001815004085887
Home item