private void transformMaterial(
      int origWidth,
      int targetWidth,
      int origHeight,
      int targetHeight,
      int origRadius,
      int targetRadius,
      ValueAnimator animation) {

    float fraction = (float) animation.getAnimatedValue();
    // update the cardView rounded corners
    mCardView.setRadius(interpolate(origRadius, targetRadius, fraction));

    // update cardview size
    if (origWidth != targetWidth) {
      mCardView.getLayoutParams().width =
          (int) ((targetWidth - origWidth) * (1 - fraction) + origWidth);
    }
    if (origHeight != targetHeight) {
      mCardView.getLayoutParams().height =
          (int) ((targetHeight - origHeight) * (1 - fraction) + origWidth);
    }

    // request the cardview to redraw
    mCardView.requestLayout();
  }