1

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();
    }
}
  • When you invoke this function? I think you should invoke it in 'onBindViewHolder' function within the adapter class. – Mohammed Alloboany Apr 13 '20 at 21:17
  • To enable others to help you, describe the exact behavior you expected, as well as how that behavior differs from what is happening with your current implementation. Include the exact text of any error messages (including, for any exceptions, the full [stack trace](https://stackoverflow.com/a/23353174) and which line of code is producing it). Please see [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example). – Ryan M Apr 13 '20 at 22:47
  • Yes, invoked in onBindViewHolder within adaptor class,but not work! – Mohamad Mahdi Rezaei Apr 13 '20 at 23:02
  • Rayan M tnx, but my question is clear, a method written that doesn't work, what else is needed? Please comment if you can help...I want this animation to run when an item is clicked. – Mohamad Mahdi Rezaei Apr 13 '20 at 23:09
  • @Mohamad Mahdi Rezaei Have you found the solution? – Krupa Kakkad Apr 12 '21 at 07:23

0 Answers0