Take a look at this small android app:
MainActivity.java:
package io.github.gsaga.toucheventtest;
import android.support.v7.app.AppCompatActivity;
i
Another solution is to wrap your image with a
, set it as your ImageView
's background
, and use tint
and tintMode
to "hide" the src
image so the background image that has the ripple over it is visible.
Not only this works on API 21+ but if your image has rounded corners – or is another type of non-rectangle shape, like a star or a heart icon – the ripple will remain in its bounds instead of filling the view's rectangle bounds, which gives a better look in some cases.
See this Medium article for an animated GIF to see how this technique compares to using a
or the foreground
attribute.