private void animateOffsetTo(
      final CoordinatorLayout coordinatorLayout, final AppBarLayout child, int offset) {
    if (mAnimator == null) {
      mAnimator = ViewUtils.createAnimator();
      mAnimator.setInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR);
      mAnimator.setUpdateListener(
          new ValueAnimatorCompat.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimatorCompat animator) {

              setHeaderTopBottomOffset(coordinatorLayout, child, animator.getAnimatedIntValue());
            }
          });
    } else {
      mAnimator.cancel();
    }
    mAnimator.setIntValues(getTopBottomOffsetForScrollingSibling(), offset);
    mAnimator.setDuration(300);
    mAnimator.start();
  }
Пример #2
0
 @Override
 public void start() {
   animator.start();
 }