mNeedleAnim.setInterpolator(new LinearInterpolator()); mAnimatorSet.play(mNeedleAnim).before(mRotateAnim); mAnimatorSet.start();
@Override Animator createAnimator() { // The amount by which mNewFrontWrapper will grow (negative value indicates shrinking). int deltaHeight = (mNewFrontWrapper.getHeight() - mBackInfobarHeight) - mOldFrontWrapper.getHeight(); int startTranslationY = Math.max(deltaHeight, 0); int endTranslationY = Math.max(-deltaHeight, 0); // Slide the front infobar down and away. AnimatorSet animator = new AnimatorSet(); mOldFrontWrapper.setTranslationY(startTranslationY); animator.play(createTranslationYAnimator(mOldFrontWrapper, startTranslationY + mOldFrontWrapper.getHeight()) .setDuration(DURATION_SLIDE_UP_MS)); // Slide the other infobars to their new positions. // Note: animator.play() causes these animations to run simultaneously. for (int i = 1; i < mInfoBarWrappers.size(); i++) { mInfoBarWrappers.get(i).setTranslationY(startTranslationY); animator.play(createTranslationYAnimator(mInfoBarWrappers.get(i), endTranslationY).setDuration(DURATION_SLIDE_UP_MS)); } mNewFrontContents.setAlpha(0f); animator.play(ObjectAnimator.ofFloat(mNewFrontContents, View.ALPHA, 1f) .setDuration(DURATION_FADE_MS)).after(DURATION_SLIDE_UP_MS); return animator; }
@TargetApi(11) private void rotateInToBack() { AnimatorSet set = new AnimatorSet(); final ObjectAnimator rotateIn = ObjectAnimator.ofFloat(this, "rotationY", 0, 90); final ObjectAnimator hideFrontView = ObjectAnimator.ofFloat(this, "alpha", 1, 0); rotateIn.setInterpolator(new AccelerateDecelerateInterpolator()); rotateIn.setDuration(300); hideFrontView.setDuration(1); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { rotateOutToBack(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); set.play(hideFrontView).after(rotateIn); set.start(); }
/** * 创建打开菜单的动画集 * * @param endTranX * @param endTranY * @param transitionLayout * @return */ @NonNull private AnimatorSet makeOpenMenuAnimatorSet(float endTranX, float endTranY, TransitionLayout transitionLayout) { endTranX = direction == ThumbnailFactory.MENU_DIRECTION_LEFT ? -endTranX : endTranX; ObjectAnimator scaleXAnima = ObjectAnimator.ofFloat( transitionLayout, "scaleX", transitionLayout.getScaleX(), thumbnailMenu.getScaleRatio()); ObjectAnimator scaleYAnima = ObjectAnimator.ofFloat( transitionLayout, "scaleY", transitionLayout.getScaleY(), thumbnailMenu.getScaleRatio()); ObjectAnimator tranXAnima = ObjectAnimator.ofFloat( transitionLayout, "translationX", transitionLayout.getTranslationX(), endTranX); ObjectAnimator tranYAnima = ObjectAnimator.ofFloat( transitionLayout, "translationY", transitionLayout.getTranslationY(), endTranY); AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(300); animSet.setInterpolator(interpolator); animSet.play(scaleXAnima).with(scaleYAnima).before(tranXAnima).before(tranYAnima); animSet.start(); return animSet; }
@TargetApi(11) private void rotateInToFront() { AnimatorSet set = new AnimatorSet(); final ObjectAnimator rotateIn = ObjectAnimator.ofFloat(this, "rotationY", 0, 90); final ObjectAnimator hideBackView = ObjectAnimator.ofFloat(this, "alpha", 1, 0); rotateIn.setDuration(300); hideBackView.setDuration(1); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { rotateOutToFront(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); set.play(hideBackView).after(rotateIn); set.start(); }
private void startFailAnim() { ValueAnimator failLeft = ValueAnimator.ofFloat(0f, 1.0f); failLeft.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { failValueRight = (float) animation.getAnimatedValue(); invalidate(); } }); ValueAnimator failRight = ValueAnimator.ofFloat(0f, 1.0f); failRight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { failValueLeft = (float) animation.getAnimatedValue(); invalidate(); } }); //组合动画,一先一后执行 AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(failLeft).after(circleAnimator).before(failRight); animatorSet.setDuration(500); animatorSet.start(); }
private void startFailAnim() { ValueAnimator failLeft = ValueAnimator.ofFloat(0f, 1.0f); failLeft.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { failValueRight = (float) animation.getAnimatedValue(); invalidate(); } }); ValueAnimator failRight = ValueAnimator.ofFloat(0f, 1.0f); failRight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { failValueLeft = (float) animation.getAnimatedValue(); invalidate(); } }); //组合动画,一先一后执行 AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(failLeft).after(circleAnimator).before(failRight); animatorSet.setDuration(500); animatorSet.start(); }
private AnimatorSet createPreLollipopIconAnimation() { AnimatorSet preLollipopAnimationSet = new AnimatorSet(); ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(getDrawable(), "scaleX", 1.0f, 0.2f); ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(getDrawable(), "scaleY", 1.0f, 0.2f); ObjectAnimator scaleInX = ObjectAnimator.ofFloat(this, "scaleX", 0.2f, 1.0f); ObjectAnimator scaleInY = ObjectAnimator.ofFloat(this, "scaleY", 0.2f, 1.0f); scaleOutX.setDuration(50); scaleOutY.setDuration(50); scaleInX.setDuration(150); scaleInY.setDuration(150); scaleInX.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { setImageResource(isOpened ? R.drawable.ic_close_vector : R.drawable.ic_menu_vector); } }); preLollipopAnimationSet.play(scaleOutX).with(scaleOutY); preLollipopAnimationSet.play(scaleInX).with(scaleInY).after(scaleOutX); preLollipopAnimationSet.setInterpolator(new OvershootInterpolator(2)); return preLollipopAnimationSet; }
private AnimatorSet getHideWithReveal(final View toHide) { final AnimatorSet animatorSet = new AnimatorSet(); binding.revealView.setVisibility(View.VISIBLE); final Animator revealAnimation = Flubber.with() .animation(RevealProvider.create(binding.floatingActionButton, binding.revealView, false)) .duration(DURATION_REVEAL) .createFor(toHide); final Animator fadeOut = Flubber.with() .animation(Flubber.AnimationPreset.FADE_IN) .interpolator(Flubber.Curve.BZR_EASE_OUT) .duration(DURATION_FADE) .listener(SimpleAnimatorListener.forEnd(animation -> toHide.setVisibility(View.INVISIBLE))) .createFor(binding.revealView); animatorSet.play(revealAnimation).after(fadeOut); return animatorSet; }
public void animateImage() { ObjectAnimator animatorX = ObjectAnimator.ofFloat(mSplashImageView, "scaleX", 1f, AppConstant.SCALE_END); ObjectAnimator animatorY = ObjectAnimator.ofFloat(mSplashImageView, "scaleY", 1f, AppConstant.SCALE_END); AnimatorSet set = new AnimatorSet(); set.setDuration(AppConstant.ANIMATION_DURATION).play(animatorX).with(animatorY); set.start(); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { startActivity(new Intent(SplashActivity.this, MainActivity.class)); SplashActivity.this.finish(); overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); } }); }
public NotificationLaunchAnimator(ViewGroup root, NotificationCardView cause, Rect epicenter, ImageView circleLayerView, int color, View[] headers, HomeScreenView homeScreenView) { Resources res = root.getResources(); int fadeDuration = res.getInteger(R.integer.app_launch_animation_header_fade_out_duration); int fadeDelay = res.getInteger(R.integer.app_launch_animation_header_fade_out_delay); Animator anim = new CircleTakeoverAnimator(cause, circleLayerView, color); anim.setDuration((long) res.getInteger(R.integer.app_launch_animation_explode_duration)); Builder builder = ((AnimatorSet) this.mDelegate).play(anim); builder.with(new MassFadeAnimator.Builder(root).setDirection(Direction.FADE_OUT).setTarget(NotificationCardView.class).setDuration((long) res.getInteger(R.integer.app_launch_animation_rec_fade_duration)).build()); builder.with(new MassSlideAnimator.Builder(root).setEpicenter(epicenter).setExclude((View) cause).setExclude(NotificationCardView.class).setFade(false).build()); for (View fadeAnimator : headers) { anim = new FadeAnimator(fadeAnimator, FadeAnimator.Direction.FADE_OUT); anim.setDuration((long) fadeDuration); anim.setStartDelay((long) fadeDelay); builder.with(anim); } } }
public NotificationLaunchAnimator(ViewGroup root, NotificationCardView cause, Rect epicenter, ImageView circleLayerView, int color, View[] headers, HomeScreenView homeScreenView) { Resources res = root.getResources(); int fadeDuration = res.getInteger(R.integer.app_launch_animation_header_fade_out_duration); int fadeDelay = res.getInteger(R.integer.app_launch_animation_header_fade_out_delay); Animator anim = new CircleTakeoverAnimator(cause, circleLayerView, color); anim.setDuration((long) res.getInteger(R.integer.app_launch_animation_explode_duration)); Builder builder = ((AnimatorSet) this.mDelegate).play(anim); builder.with(new MassFadeAnimator.Builder(root).setDirection(MassFadeAnimator.Direction.FADE_OUT).setTarget(NotificationCardView.class).setDuration((long) res.getInteger(R.integer.app_launch_animation_rec_fade_duration)).build()); builder.with(new MassSlideAnimator.Builder(root).setEpicenter(epicenter).setExclude((View) cause).setExclude(NotificationCardView.class).setFade(false).build()); for (View fadeAnimator : headers) { anim = new FadeAnimator(fadeAnimator, FadeAnimator.Direction.FADE_OUT); anim.setDuration((long) fadeDuration); anim.setStartDelay((long) fadeDelay); builder.with(anim); } } }
public void playTo(int position) { for (ImageView iv : mImageViews) { iv.setImageBitmap(bmpNomal); } mImageViews.get(position).setImageBitmap(bmpSelect); final ImageView imageViewStrat = mImageViews.get(position); ObjectAnimator animIn1 = ObjectAnimator.ofFloat(imageViewStrat, "scaleX", 0.25f, 1.0f); ObjectAnimator animIn2 = ObjectAnimator.ofFloat(imageViewStrat, "scaleY", 0.25f, 1.0f); if (mPlayToAnimatorSet != null && mPlayToAnimatorSet.isRunning()) { mPlayToAnimatorSet.cancel(); mPlayToAnimatorSet = null; } mPlayToAnimatorSet = new AnimatorSet(); mPlayToAnimatorSet.play(animIn1).with(animIn2); mPlayToAnimatorSet.setDuration(100); mPlayToAnimatorSet.start(); }
@SuppressLint({"NewApi"}) protected void animateToState(final boolean paramBoolean) { if (this.mAnimator != null) { this.mAnimator.cancel(); this.mAnimator = null; } AnimatorSet localAnimatorSet = new AnimatorSet(); ObjectAnimator localObjectAnimator1 = ObjectAnimator.ofInt(this, "SliderOffset", new int[]{paramBoolean ? this.mSliderPositionEnd : this.mSliderPositionStart}); ObjectAnimator localObjectAnimator2 = ObjectAnimator.ofInt(this, "SliderOnAlpha", new int[]{paramBoolean ? 'ÿ' : 0}); localObjectAnimator2.setDuration(180L); localObjectAnimator1.setDuration(180L); localAnimatorSet.play(localObjectAnimator2).after(localObjectAnimator1).after(100L); this.mAnimator = localAnimatorSet; this.mAnimator.addListener(this.mAnimatorListener); this.mAnimator.start(); }
private void startAnim() { ObjectAnimator animatorX = ObjectAnimator.ofFloat(mIVEntry, "scaleX", 1f, SCALE_END); ObjectAnimator animatorY = ObjectAnimator.ofFloat(mIVEntry, "scaleY", 1f, SCALE_END); AnimatorSet set = new AnimatorSet(); set.setDuration(ANIM_TIME).play(animatorX).with(animatorY); set.start(); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { startActivity(new Intent(WelcomeActivity.this, MainActivity.class)); WelcomeActivity.this.finish(); } }); }
private Animator getShowWithReveal(final View toShow) { final AnimatorSet animatorSet = new AnimatorSet(); toShow.setVisibility(View.INVISIBLE); toShow.setAlpha(1); final Animator reveal = Flubber.with() .animation(RevealProvider.create(binding.floatingActionButton, binding.revealView, true)) .duration(DURATION_REVEAL) .createFor(toShow); final Animator fadeOut = Flubber.with() .animation(Flubber.AnimationPreset.FADE_OUT) .interpolator(Flubber.Curve.BZR_EASE_OUT) .duration(DURATION_FADE) .createFor(binding.revealView); animatorSet.play(fadeOut).after(reveal); return animatorSet; }
/** * 缩小 * * @param view */ public void zoomIn(final View view, float dist) { view.setPivotY(view.getHeight()); view.setPivotX(view.getWidth() / 2); AnimatorSet mAnimatorSet = new AnimatorSet(); ObjectAnimator mAnimatorScaleX = ObjectAnimator.ofFloat(view, "scaleX", 1.0f, scale); ObjectAnimator mAnimatorScaleY = ObjectAnimator.ofFloat(view, "scaleY", 1.0f, scale); ObjectAnimator mAnimatorTranslateY = ObjectAnimator.ofFloat(view, "translationY", 0.0f, -dist); mAnimatorSet.play(mAnimatorTranslateY).with(mAnimatorScaleX).with(mAnimatorScaleY); mAnimatorSet.setDuration(300); mAnimatorSet.start(); }
/** * 缩小 * @param view */ public void zoomIn(final View view, float dist) { view.setPivotY(view.getHeight()); view.setPivotX(view.getWidth() / 2); AnimatorSet mAnimatorSet = new AnimatorSet(); ObjectAnimator mAnimatorScaleX = ObjectAnimator.ofFloat(view, "scaleX", 1.0f, scale); ObjectAnimator mAnimatorScaleY = ObjectAnimator.ofFloat(view, "scaleY", 1.0f, scale); ObjectAnimator mAnimatorTranslateY = ObjectAnimator.ofFloat(view, "translationY", 0.0f, -dist); mAnimatorSet.play(mAnimatorTranslateY).with(mAnimatorScaleX); mAnimatorSet.play(mAnimatorScaleX).with(mAnimatorScaleY); mAnimatorSet.setDuration(300); mAnimatorSet.start(); }
private void newHideAnim() { ObjectAnimator translationHide = ObjectAnimator.ofFloat(rvAlbumItems, "translationY", 0, mBottomBar.getTop()); ObjectAnimator alphaHide = ObjectAnimator.ofFloat(rootViewAlbumItems, "alpha", 1.0f, 0.0f); translationHide.setDuration(200); setHide = new AnimatorSet(); setHide.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); rootViewAlbumItems.setVisibility(View.GONE); } }); setHide.setInterpolator(new AccelerateInterpolator()); setHide.play(translationHide).with(alphaHide); }