Exemplo n.º 1
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @SuppressLint("NewApi")
  private void init() {
    mXAnimator = ObjectAnimator.ofFloat(this, "x", 0);
    mYAnimator = ObjectAnimator.ofFloat(this, "y", 0);
    mWAnimator = ObjectAnimator.ofInt(this, "wid", 0);
    mHAnimator = ObjectAnimator.ofInt(this, "hei", 0);
    mAnimatorSet = new AnimatorSet();
    mAnimatorSet.setDuration(AnimationDuration);
    mAnimatorSet.playTogether(mWAnimator, mHAnimator, mXAnimator, mYAnimator);
    mAnimatorSet.addListener(
        new AnimatorListener() {

          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {
            if (getVisibility() != View.VISIBLE) {
              setVisibility(View.VISIBLE);
            }
          }

          @Override
          public void onAnimationCancel(Animator animation) {}
        });
  }
Exemplo n.º 2
0
 public void collapse() {
   if (mExpanded) {
     mExpanded = false;
     mCollapseAnimation.start();
     mExpandAnimation.cancel();
   }
 }
Exemplo n.º 3
0
  public void showFullToolbar(int duration) {
    mIsToolbarShown = true;

    final AnimatorSet animatorSet =
        buildAnimationSet(
            duration,
            buildAnimation(mToolbarView, -mToolbarHeight, 0),
            buildAnimation(mTitle, -mToolbarHeight, 0));

    animatorSet.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animator) {
            updateFlexibleSpaceText(mScrollY); // dirty update fling-fix
          }

          @Override
          public void onAnimationEnd(Animator animator) {
            updateFlexibleSpaceText(mScrollY); // dirty update fling-fix
          }

          @Override
          public void onAnimationCancel(Animator animator) {}

          @Override
          public void onAnimationRepeat(Animator animator) {}
        });

    animatorSet.start();
  }
  private AnimatorSet createAnimationSet() {
    List<Animator> animators = new ArrayList<>();
    view.setLayerType(View.LAYER_TYPE_HARDWARE, null);

    if (!objectAnimations.isEmpty())
      for (AnimationParams customAnimation : objectAnimations) {
        animators.add(createAnimation(view, customAnimation));
      }

    if (this.animators != null)
      for (Animator animator : this.animators) {
        animators.add(animator);
      }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(animators);
    if (interpolator != null) {
      animatorSet.setInterpolator(interpolator);
    }
    animatorSet.setDuration(duration);
    animatorSet.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            view.setLayerType(View.LAYER_TYPE_NONE, null);
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setLayerType(View.LAYER_TYPE_NONE, null);
          }
        });
    return animatorSet;
  }
Exemplo n.º 5
0
  private void startAnimation(View img, final Intent intent) {
    // ObjectAnimator oaTranslationX = ObjectAnimator.ofFloat(img,
    // "translationX", 0, mScreenWidth / 2);
    // ObjectAnimator oaTranslationY = ObjectAnimator.ofFloat(img,
    // "translationY", 0, mScreenHeight / 2);
    ObjectAnimator oaScaleX = ObjectAnimator.ofFloat(img, "scaleX", 0.5f, 1.2f, 1f);
    ObjectAnimator oaScaleY = ObjectAnimator.ofFloat(img, "scaleY", 0.5f, 1.2f, 1f);

    // oaTranslationX.setDuration(1000);
    // oaTranslationY.setDuration(1000);
    // oaScaleX.setDuration(1000);
    // oaScaleY.setDuration(1000);
    AnimatorSet set = new AnimatorSet();
    set.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationStart(Animator animation) {
            isLocked = true;
            super.onAnimationStart(animation);
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            Log.e("", "动画完成");
            isLocked = false;

            startActivity(intent);
          }
        });
    set.play(oaScaleX).with(oaScaleY);
    set.setDuration(500);
    if (!isLocked) {
      set.start();
    }
  }
 private void applyMode(int mode, boolean animate) {
   if (mLeftSide == null) return; // pre-init
   float newAlpha = getNonBatteryClockAlphaFor(mode);
   float newAlphaBC = getBatteryClockAlpha(mode);
   if (mCurrentAnimation != null) {
     mCurrentAnimation.cancel();
   }
   if (animate) {
     AnimatorSet anims = new AnimatorSet();
     anims.playTogether(
         animateTransitionTo(mLeftSide, newAlpha),
         animateTransitionTo(mStatusIcons, newAlpha),
         animateTransitionTo(mSignalCluster, newAlpha),
         animateTransitionTo(mNetworkTraffic, newAlpha),
         animateTransitionTo(mBattery, newAlphaBC),
         animateTransitionTo(mClock, newAlphaBC));
     if (isLightsOut(mode)) {
       anims.setDuration(LIGHTS_OUT_DURATION);
     }
     anims.start();
     mCurrentAnimation = anims;
   } else {
     mLeftSide.setAlpha(newAlpha);
     mStatusIcons.setAlpha(newAlpha);
     mSignalCluster.setAlpha(newAlpha);
     mNetworkTraffic.setAlpha(newAlpha);
     mBattery.setAlpha(newAlphaBC);
     mClock.setAlpha(newAlphaBC);
   }
 }
  private void animateHide() {
    bubbleHideAnimator = new AnimatorSet();
    this.setPivotX(this.getWidth());
    this.setPivotY(this.getHeight());
    Animator shrinkerX =
        ObjectAnimator.ofFloat(this, SCALE_X, 1f, 0f).setDuration(BUBBLE_ANIMATION_DURATION);
    Animator shrinkerY =
        ObjectAnimator.ofFloat(this, SCALE_Y, 1f, 0f).setDuration(BUBBLE_ANIMATION_DURATION);
    Animator alpha =
        ObjectAnimator.ofFloat(this, ALPHA, 1f, 0f).setDuration(BUBBLE_ANIMATION_DURATION);
    bubbleHideAnimator.setInterpolator(new AccelerateInterpolator());
    bubbleHideAnimator.playTogether(shrinkerX, shrinkerY, alpha);
    bubbleHideAnimator.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            FastScrollBubble.this.setVisibility(INVISIBLE);
            bubbleHideAnimator = null;
          }

          @Override
          public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            FastScrollBubble.this.setVisibility(INVISIBLE);
            bubbleHideAnimator = null;
          }
        });
    bubbleHideAnimator.start();
  }
  @Override
  public void onTextSizeChanged(final TextView textView, float oldSize) {
    if (mCurrentState != CalculatorState.INPUT) { // TODO dont animate when showing graph
      // Only animate text changes that occur from user input.
      return;
    }

    // Calculate the values needed to perform the scale and translation animations,
    // maintaining the same apparent baseline for the displayed text.
    final float textScale = oldSize / textView.getTextSize();
    final float translationX;
    if (android.os.Build.VERSION.SDK_INT >= 17) {
      translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - textView.getPaddingEnd());
    } else {
      translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - textView.getPaddingRight());
    }
    final float translationY =
        (1.0f - textScale) * (textView.getHeight() / 2.0f - textView.getPaddingBottom());
    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
        ObjectAnimator.ofFloat(textView, View.SCALE_X, textScale, 1.0f),
        ObjectAnimator.ofFloat(textView, View.SCALE_Y, textScale, 1.0f),
        ObjectAnimator.ofFloat(textView, View.TRANSLATION_X, translationX, 0.0f),
        ObjectAnimator.ofFloat(textView, View.TRANSLATION_Y, translationY, 0.0f));
    animatorSet.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.start();
  }
Exemplo n.º 9
0
  // Define Animations
  public void initializeAnimatorSets() {
    rotate = new AnimatorSet();
    unrotate = new AnimatorSet();
    Animator[] rotationAnimations = new Animator[getChildCount() * 2];

    // set rotate
    float spaceForEach =
        (float) (Math.cos((double) MapView.rotationAngle) * MapView.rotationYScale * getHeight());
    for (int i = 0; i < getChildCount(); i++) {
      ((MapView) getChildAt(i)).initPivots();
      rotationAnimations[2 * i] =
          new ObjectAnimator()
              .ofFloat(
                  getChildAt(getChildCount() - i - 1),
                  "translationY",
                  (float)
                      ((i - activeLayer) * spaceForEach
                          - (getHeight() - spaceForEach)
                              / 2)); // the "getChildCount() - i - 1" bit reverses the ordering of
                                     // the layers. Good candidate for refactoring
      rotationAnimations[2 * i + 1] = ((MapView) getChildAt(getChildCount() - i - 1)).rotate;
    }
    for (int i = 0; i < rotationAnimations.length - 1; i++) {
      rotate.play(rotationAnimations[i]).with(rotationAnimations[i + 1]);
    }

    // set unrotate
    unrotate.play(ObjectAnimator.ofInt(this, "scrollY", 0));
  }
Exemplo n.º 10
0
  /** 下落 */
  public void freeFall() {

    ObjectAnimator objectAnimator =
        ObjectAnimator.ofFloat(shapeLoadingView, "translationY", 0, mDistance);
    ObjectAnimator scaleIndication = ObjectAnimator.ofFloat(indicationIm, "scaleX", 1, 0.2f);

    objectAnimator.setDuration(ANIMATION_DURATION);
    objectAnimator.setInterpolator(new AccelerateInterpolator());
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(ANIMATION_DURATION);
    animatorSet.playTogether(objectAnimator, scaleIndication);
    animatorSet.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {

            shapeLoadingView.changeShape();
            upThrow();
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    animatorSet.start();
  }
Exemplo n.º 11
0
  private void stopAnimator() {
    ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(this, "scaleX", 1, 0);
    ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(this, "scaleY", 1, 0);
    scaleXAnimator.setDuration(300);
    scaleXAnimator.setInterpolator(new LinearInterpolator());
    scaleYAnimator.setDuration(300);
    scaleYAnimator.setInterpolator(new LinearInterpolator());
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
    animatorSet.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {
            isStart = false;
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    animatorSet.start();
  }
Exemplo n.º 12
0
 public void expand() {
   if (!mExpanded) {
     mExpanded = true;
     mCollapseAnimation.cancel();
     mExpandAnimation.start();
   }
 }
  /** 开启打开动画 */
  private void startAnim() {
    ObjectAnimator tranAnimY = ObjectAnimator.ofFloat(mMenuViewSmall, "translationY", 0, -20);
    ObjectAnimator tranAnimPointX =
        ObjectAnimator.ofFloat(mMenuViewSmall, "translationX", 0, viewMoveX);
    ObjectAnimator tranAnimPointY =
        ObjectAnimator.ofFloat(mMenuViewSmall, "translationY", -20, viewMoveY);
    ObjectAnimator scaleAnimX =
        ObjectAnimator.ofFloat(mMenuViewSmall, "scaleX", 1.0f, (toValueX + 1.0f));
    ObjectAnimator scaleAnimY =
        ObjectAnimator.ofFloat(mMenuViewSmall, "scaleY", 1.0f, (toValueY + 1.0f));
    AnimatorSet set = new AnimatorSet();
    set.setDuration(500);
    set.play(tranAnimY)
        .before(tranAnimPointX)
        .before(tranAnimPointY)
        .before(scaleAnimX)
        .before(scaleAnimY);

    scaleAnimX.addUpdateListener(
        new AnimatorUpdateListener() {

          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            float value = (float) animation.getAnimatedValue();
            //				mMenuViewSmall.setScaleX(value);
            mContentView.setAlpha((float) (1 - ((value - 1) / toValueX) * 0.5));
            mContentView.setScaleX((float) (1 - ((value - 1) / toValueX) * 0.2));
            mContentView.setScaleY((float) (1 - ((value - 1) / toValueX) * 0.2));
          }
        });

    set.addListener(this);
    set.start();
  }
Exemplo n.º 14
0
  private AnimatorSet startAniMoveRightToCenter(View rightDot) {
    int dotDiameter = (int) getResources().getDimension(R.dimen.loading_dot_size);
    int dotPadding = (int) getResources().getDimension(R.dimen.loading_dot_padding);
    AnimatorSet moveRightToCentral = new AnimatorSet();
    ObjectAnimator rightDotToCentral =
        ObjectAnimator.ofFloat(rightDot, "translationX", 0, -dotPadding - dotDiameter);

    rightDotColorChange =
        ValueAnimator.ofObject(
            new ArgbEvaluator(),
            getResources().getColor(R.color.dot_normal),
            getResources().getColor(R.color.dot_active));
    final GradientDrawable rightDotBg = (GradientDrawable) rightDot.getBackground();
    rightDotColorChange.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(final ValueAnimator animator) {
            rightDotBg.setColor((Integer) animator.getAnimatedValue());
          }
        });
    rightDotColorChange.setDuration(aniDuration);
    rightDotColorChange.addListener(this);
    moveRightToCentral.play(rightDotColorChange).with(rightDotToCentral);
    return moveRightToCentral;
  }
Exemplo n.º 15
0
 private void startTrans() {
   ObjectAnimator animator = ObjectAnimator.ofFloat(this, "translationX", 0, width / 3);
   animator.setDuration(200);
   animator.setInterpolator(new DecelerateInterpolator());
   ObjectAnimator animator2 = ObjectAnimator.ofFloat(this, "translationX", width / 3, -width / 4);
   animator2.setDuration(200);
   animator2.setInterpolator(new DecelerateInterpolator());
   ObjectAnimator animator3 = ObjectAnimator.ofFloat(this, "translationX", -width / 4, width / 5);
   animator3.setDuration(200);
   animator3.setInterpolator(new DecelerateInterpolator());
   ObjectAnimator animator4 = ObjectAnimator.ofFloat(this, "translationX", width / 5, -width / 6);
   animator4.setDuration(200);
   animator4.setInterpolator(new DecelerateInterpolator());
   ObjectAnimator animator5 = ObjectAnimator.ofFloat(this, "translationX", -width / 6, 0);
   animator5.setDuration(200);
   animator5.setInterpolator(new DecelerateInterpolator());
   AnimatorSet set = new AnimatorSet();
   List<Animator> items = new ArrayList<Animator>();
   items.add(animator);
   items.add(animator2);
   items.add(animator3);
   items.add(animator4);
   items.add(animator5);
   set.playSequentially(items);
   set.start();
 }
Exemplo n.º 16
0
        @Override
        public void dispatchMessage(Message msg) {
          switch (msg.what) {
            case START_FOCUS_MSG:
              // 开始对焦操作
              _startFocus((PointF) msg.obj);

              break;

            case FINISH_FOCUS_MSG:
              animSet.end(); // 结束动画
              FocusView.this.setColorFilter(ColorUtil.FOCUS_COLOR); // 改变图标的颜色

              break;

            case DISAPPEAR_MSG:
              // 将控件消失
              FocusView.this.clearColorFilter(); // 清除颜色过滤
              FocusView.this.setVisibility(View.GONE); // 控件不可见

              break;
            case CANCEL_FOCUS_MSG:
              /** 停止对焦操作 */
              animSet.cancel(); // 取消动画

              FocusView.this.clearColorFilter(); // 清除颜色过滤
              FocusView.this.setVisibility(View.GONE); // 控件不可见

              break;
          }
        }
 private void performSwitch() {
   ObjectAnimator animator1 =
       ObjectAnimator.ofFloat(
           mFirstView, "translationY", mFirstView.getTranslationY() - mBannerHeight);
   ObjectAnimator animator2 =
       ObjectAnimator.ofFloat(
           mSecondView, "translationY", mSecondView.getTranslationY() - mBannerHeight);
   AnimatorSet set = new AnimatorSet();
   set.playTogether(animator1, animator2);
   set.addListener(
       new AnimatorListenerAdapter() {
         @Override
         public void onAnimationEnd(Animator animation) {
           mFirstView.setTranslationY(0);
           mSecondView.setTranslationY(0);
           View removedView = getChildAt(0);
           mPosition++;
           mAdapter.setItem(removedView, mAdapter.getItem(mPosition % mAdapter.getCount()));
           removeView(removedView);
           addView(removedView, 1);
         }
       });
   set.setDuration(mAnimDuration);
   set.start();
 }
Exemplo n.º 18
0
  private void hideMenu(int cx, int cy, float startRadius, float endRadius) {
    List<Animator> animList = new ArrayList<>();

    for (int i = arcLayout.getChildCount() - 1; i >= 0; i--) {
      animList.add(createHideItemAnimator(arcLayout.getChildAt(i)));
    }

    animList.add(createHideItemAnimator(centerItem));

    Animator revealAnim = createCircularReveal(menuLayout, cx, cy, startRadius, endRadius);
    revealAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    revealAnim.setDuration(200);
    revealAnim.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            menuLayout.setVisibility(View.INVISIBLE);
          }
        });

    animList.add(revealAnim);

    AnimatorSet animSet = new AnimatorSet();
    animSet.playSequentially(animList);
    animSet.start();
  }
Exemplo n.º 19
0
  private void flip(final View v1, final View v2, final boolean scale, boolean reverse) {
    final int duration = 300;
    final int degree = reverse ? 90 : -90;
    final int degree2 = -degree;

    final ObjectAnimator a, b;
    if (!scale) {
      a = ObjectAnimator.ofFloat(v1, "rotationY", 0, degree);
      b = ObjectAnimator.ofFloat(v2, "rotationY", degree2, 0);
    } else {
      final float scaleX = 0.5f;
      final float scaleY = 0.5f;
      a =
          ObjectAnimator.ofPropertyValuesHolder(
              v1,
              PropertyValuesHolder.ofFloat("rotationY", 0, degree),
              PropertyValuesHolder.ofFloat("scaleX", 1, scaleX),
              PropertyValuesHolder.ofFloat("scaleY", 1, scaleY));
      b =
          ObjectAnimator.ofPropertyValuesHolder(
              v2,
              PropertyValuesHolder.ofFloat("rotationY", degree2, 0),
              PropertyValuesHolder.ofFloat("scaleX", scaleX, 1),
              PropertyValuesHolder.ofFloat("scaleY", scaleY, 1));
    }

    a.setInterpolator(new LinearInterpolator());
    b.setInterpolator(new LinearInterpolator());
    a.setDuration(duration);
    b.setDuration(duration);

    a.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {
            v1.setVisibility(View.GONE);
            v2.setVisibility(View.VISIBLE);
            if (scale) { // 恢复scale
              v1.setScaleX(1);
              v1.setScaleY(1);
            }
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    v1.setVisibility(View.VISIBLE);
    v2.setVisibility(View.GONE);

    AnimatorSet set = new AnimatorSet();
    set.play(a).before(b);
    set.start();
  }
Exemplo n.º 20
0
 /**
  * 创建移动动画
  *
  * @param view
  * @param startX
  * @param endX
  * @param startY
  * @param endY
  * @return
  */
 private AnimatorSet createTranslationAnimations(
     View view, float startX, float endX, float startY, float endY) {
   ObjectAnimator animX = ObjectAnimator.ofFloat(view, "translationX", startX, endX);
   ObjectAnimator animY = ObjectAnimator.ofFloat(view, "translationY", startY, endY);
   AnimatorSet animSetXY = new AnimatorSet();
   animSetXY.playTogether(animX, animY);
   return animSetXY;
 }
 public void animateHidden() {
   if (!mIsHiddenOrHiding) {
     mVisibleAnimator.cancel();
     mHiddenAnimator.end();
     mHiddenAnimator.start();
   }
   mIsHiddenOrHiding = true;
 }
Exemplo n.º 22
0
 /** Starts the animation. */
 public void start() {
   resetAllPaths();
   animatorSet.cancel();
   animatorSet.setDuration(duration);
   animatorSet.setInterpolator(interpolator);
   animatorSet.setStartDelay(delay);
   animatorSet.start();
 }
 public static AnimatorSet getScaleAnimator(View view, float startScale, float endScale) {
   AnimatorSet set = new AnimatorSet();
   ObjectAnimator scaleXAnimator =
       ObjectAnimator.ofFloat(view, View.SCALE_X, startScale, endScale);
   ObjectAnimator scaleYAnimator =
       ObjectAnimator.ofFloat(view, View.SCALE_Y, startScale, endScale);
   set.playTogether(scaleXAnimator, scaleYAnimator);
   return set;
 }
  @Override
  public void showFabs() {
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(hideTextContainer());
    animatorSet.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {
            animatedTextContainer = true;
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            textContainerisShown = false;

            ViewGroup.MarginLayoutParams lp =
                (ViewGroup.MarginLayoutParams) viewHolder.rvChat.getLayoutParams();
            Log.d(
                "height = ",
                String.valueOf(
                    ((ViewGroup.LayoutParams) viewHolder.textContainer.getLayoutParams()).height));
            lp.setMargins(lp.leftMargin, lp.topMargin, lp.rightMargin, 0);

            viewHolder.rvChat.requestLayout();
            viewHolder.rvChat.scrollToPosition(0);

            viewHolder.fabAdd.setImageResource(R.drawable.add);
            AnimatorSet newAnimatorSet = new AnimatorSet();
            viewHolder.fabAdd.setAlpha(0.64f);
            newAnimatorSet.playTogether(createExpandAnimator(viewHolder.fabAdd, offset));
            newAnimatorSet.addListener(
                new Animator.AnimatorListener() {
                  @Override
                  public void onAnimationStart(Animator animation) {}

                  @Override
                  public void onAnimationEnd(Animator animation) {
                    animatedTextContainer = false;
                  }

                  @Override
                  public void onAnimationCancel(Animator animation) {}

                  @Override
                  public void onAnimationRepeat(Animator animation) {}
                });
            newAnimatorSet.start();
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    animatorSet.start();
  }
Exemplo n.º 25
0
 private void combine() {
   ObjectAnimator moveIn = ObjectAnimator.ofFloat(tv, "translationX", -500f, 0f);
   ObjectAnimator rotate = ObjectAnimator.ofFloat(tv, "rotation", 0f, 360f);
   ObjectAnimator fadeInOut = ObjectAnimator.ofFloat(tv, "alpha", 1f, 0f, 1f);
   AnimatorSet animSet = new AnimatorSet();
   animSet.play(rotate).with(fadeInOut).after(moveIn);
   animSet.setDuration(5000);
   animSet.start();
 }
Exemplo n.º 26
0
 public void hideFullToolbar() {
   mIsToolbarShown = false;
   final AnimatorSet animatorSet =
       buildAnimationSet(
           250,
           buildAnimation(mToolbarView, 0, -mToolbarHeight),
           buildAnimation(mTitle, 0, -mToolbarHeight));
   animatorSet.start();
 }
 /**
  * Creates a "grow and fade in from the bottom" animation for the specified view.
  *
  * @param view The view to animate
  */
 private static AnimatorSet createGrowFadeInFromBottom(View view) {
   AnimatorSet growFadeInFromBottomAnimation = new AnimatorSet();
   growFadeInFromBottomAnimation.playTogether(
       ObjectAnimator.ofFloat(view, View.SCALE_X, 0.5f, 1).setDuration(125),
       ObjectAnimator.ofFloat(view, View.SCALE_Y, 0.5f, 1).setDuration(125),
       ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1).setDuration(75));
   growFadeInFromBottomAnimation.setStartDelay(50);
   return growFadeInFromBottomAnimation;
 }
 private void setTargetInternal(Object target, Animator animator) {
   if (animator instanceof AnimatorSet) {
     AnimatorSet set = ((AnimatorSet) animator);
     for (Animator child : set.getChildAnimations()) {
       setTargetInternal(target, child);
     }
   } else {
     animator.setTarget(target);
   }
 }
Exemplo n.º 29
0
  /** 初始化属性 */
  private void init() {
    // x y方向上的缩放
    ObjectAnimator xScaleAnimator = ObjectAnimator.ofFloat(this, "scaleX", START_SCALE, END_SCALE);
    ObjectAnimator yScaleAnimator = ObjectAnimator.ofFloat(this, "scaleY", START_SCALE, END_SCALE);

    // 组合动画
    animSet = new AnimatorSet();
    animSet.play(xScaleAnimator).with(yScaleAnimator);
    animSet.setDuration(SCALE_DURATION);
  }
 /**
  * Creates a "shrink and fade out from bottom" animation for the specified view.
  *
  * @param view The view to animate
  * @param listener The animation listener
  */
 private static AnimatorSet createShrinkFadeOutFromBottomAnimation(
     View view, Animator.AnimatorListener listener) {
   AnimatorSet shrinkFadeOutFromBottomAnimation = new AnimatorSet();
   shrinkFadeOutFromBottomAnimation.playTogether(
       ObjectAnimator.ofFloat(view, View.SCALE_Y, 1, 0.5f).setDuration(125),
       ObjectAnimator.ofFloat(view, View.ALPHA, 1, 0).setDuration(75));
   shrinkFadeOutFromBottomAnimation.setStartDelay(150);
   shrinkFadeOutFromBottomAnimation.addListener(listener);
   return shrinkFadeOutFromBottomAnimation;
 }