Android How To Create Ripple Effect In Java
I have the ripple xml. But I am not sure how to get same effect in Java.
Solution 1:
You can create or modify a RippleDrawable
at run time using something like:
ColorStateListcsl= ColorStateList.valueOf(Color.BLUE);
RippleDrawabled=newRippleDrawable(csl, null, null);
// Change the color, if desired.ColorStateListotherCsl= ColorStateList.valueOf(Color.RED);
d.setColor(otherCsl);
Solution 2:
You can't use the default rippleview in android below api 21 You need to make a custom view with animation on touch. or you can easy use this one to add ripple to views: https://github.com/balysv/material-ripple
To add ripple from java :
MaterialRippleLayout.on(view)
.rippleColor(Color.BLACK)
.create();
Post a Comment for "Android How To Create Ripple Effect In Java"