I want to circular reveal animation for recycler view items. I put the following code in the adapter class but it doesn't work. please help me.
public void anim(final CustomViewHolder customViewHolder) {
// get the center for the clipping circle
int centerX = (customViewHolder.imageView.getLeft() + customViewHolder.imageView.getRight()) / 2;
int centerY = (customViewHolder.imageView.getTop() + customViewHolder.imageView.getBottom()) / 2;
int startRadius = 0;
// get the final radius for the clipping circle
int endRadius = Math.max(customViewHolder.imageView.getWidth(), customViewHolder.imageView.getHeight());
// create the animator for this view (the start radius is zero)
Animator anim =
null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
anim = ViewAnimationUtils.createCircularReveal(customViewHolder.rv,
centerX, centerY, startRadius, endRadius);
anim.setDuration(1000);
// make the view invisible when the animation is done
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
});
customViewHolder.rv.setVisibility(View.VISIBLE);
anim.start();
}
}