Basic ripple setup
-
Ripples contained within the view.
android:background="?selectableItemBackground"
-
Ripples that extend beyond the view’s bounds:
android:background="?selectableItemBackgroundBorderless"
Have a look here for resolving
?(attr)
xml references in Java code.
Support Library
- Using
?attr:
(or the?
shorthand) instead of?android:attr
references the support library, so is available back to API 7.
Ripples with images/backgrounds
- To have a image or background and overlaying ripple the easiest solution is to wrap the
View
in aFrameLayout
with the ripple set withsetForeground()
orsetBackground()
.
Honestly there is no clean way of doing this otherwise.