static void setBackgroundWithRipple(View clickedView, final View backgroundView,
                                        final View bgOverlay, final int newColor, int animationDuration) {
        int centerX = (int) (clickedView.getX() + (clickedView.getMeasuredWidth() / 2));
        int centerY = clickedView.getMeasuredHeight() / 2;
        int finalRadius = backgroundView.getWidth();

        backgroundView.clearAnimation();
        bgOverlay.clearAnimation();

        Animator circularReveal;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            circularReveal = ViewAnimationUtils
                    .createCircularReveal(bgOverlay, centerX, centerY, 0, finalRadius);
        } else {
            bgOverlay.setAlpha(0);
            circularReveal = ObjectAnimator.ofFloat(bgOverlay, "alpha", 0, 1);
        }

        circularReveal.setDuration(animationDuration);
        circularReveal.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                onCancel();
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                onCancel();
            }

            private void onCancel() {
                backgroundView.setBackgroundColor(newColor);
                bgOverlay.setVisibility(View.GONE);
            }
        });

        bgOverlay.setBackgroundColor(newColor);
        bgOverlay.setVisibility(View.VISIBLE);
        circularReveal.start();
    }
static void setBackgroundWithRipple ( View clickedView , final View backgroundView , final View bgOverlay , final int newColor , int animationDuration ) { int centerX = ( int ) ( clickedView . getX ( ) + ( clickedView . getMeasuredWidth ( ) / 2 ) ) ; int centerY = clickedView . getMeasuredHeight ( ) / 2 ; int finalRadius = backgroundView . getWidth ( ) ; backgroundView . clearAnimation ( ) ; bgOverlay . clearAnimation ( ) ; Animator circularReveal ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP ) { circularReveal = ViewAnimationUtils . createCircularReveal ( bgOverlay , centerX , centerY , 0 , finalRadius ) ; } else { bgOverlay . setAlpha ( 0 ) ; circularReveal = ObjectAnimator . ofFloat ( bgOverlay , "alpha" , 0 , 1 ) ; } circularReveal . setDuration ( animationDuration ) ; circularReveal . addListener ( new AnimatorListenerAdapter ( ) { @ Override public void onAnimationEnd ( Animator animation ) { onCancel ( ) ; } @ Override public void onAnimationCancel ( Animator animation ) { onCancel ( ) ; } private void onCancel ( ) { backgroundView . setBackgroundColor ( newColor ) ; bgOverlay . setVisibility ( View . GONE ) ; } } ) ; bgOverlay . setBackgroundColor ( newColor ) ; bgOverlay . setVisibility ( View . VISIBLE ) ; circularReveal . start ( ) ; }
Used to set the ripple animation when a tab is selected

@param clickedView       the view that is clicked (to get dimens where ripple starts)
@param backgroundView    temporary view to which final background color is set
@param bgOverlay         temporary view which is animated to get ripple effect
@param newColor          the new color i.e ripple color
@param animationDuration duration for which animation runs