How to Set a Ripple Effect on Textview or Imageview on Android

How to set a ripple effect on textview or imageview on Android?

Ref : http://developer.android.com/training/material/animations.html,

http://wiki.workassis.com/category/android/android-xml/

<TextView
.
.
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
/>

<ImageView
.
.
.
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
/>

Native Round Ripple Effect For ImageView

You should use

android:background="?attr/selectableItemBackgroundBorderless"

Ripple effect over imageview

Add android:background="@null" for the ImageView

onRecieve show a single ripple effect on imageView

Call stopRippleAnimation after the ripple animation duration.

Also you can easily perform this animation using valueAnimator, Fadeout and scale using the values between 0 and 1.

Ripple effect is not going above the ImageView

Few days back I was also facing same issue. I solved my issue by wrapping ImageView inside FrameLayout and applying android:foreground property on FrameLayout. You also have to set android:clickable property of FrameLayout to true or should set onClickListener to FrameLayout.

Please check my answer in following thread in following link.

Let me know if it helps.



Related Topics



Leave a reply



Submit