Пример #1
0
  public RotateAnimation setPivot(int pivot) {
    this.pivot = pivot;

    float pivotX, pivotY, viewWidth = targetView.getWidth(), viewHeight = targetView.getHeight();
    switch (pivot) {
      case PIVOT_TOP_LEFT:
        pivotX = 1f;
        pivotY = 1f;
        break;
      case PIVOT_TOP_RIGHT:
        pivotX = viewWidth;
        pivotY = 1f;
        break;
      case PIVOT_BOTTOM_LEFT:
        pivotX = 1f;
        pivotY = viewHeight;
        break;
      case PIVOT_BOTTOM_RIGHT:
        pivotX = viewWidth;
        pivotY = viewHeight;
        break;
      default:
        pivotX = viewWidth / 2;
        pivotY = viewHeight / 2;
        break;
    }
    ViewHelper.setPivotX(targetView, pivotX);
    ViewHelper.setPivotY(targetView, pivotY);

    return this;
  }
Пример #2
0
  @Override
  public AnimatorSet createAnimatorSet() {
    ViewHelper.setClipChildren(targetView, false);

    AnimatorSet rotationSet = new AnimatorSet();
    rotationSet.play(
        ObjectAnimator.ofFloat(targetView, View.ROTATION, targetView.getRotation() + degrees));
    rotationSet.setInterpolator(interpolator);
    rotationSet.setDuration(duration);
    if (listener != null) {
      rotationSet.addListener(listener);
    }

    return rotationSet;
  }