List of usage examples for android.animation AnimatorSet play
public Builder play(Animator anim)
Builder
object, which is used to set up playing constraints. From source file:Main.java
public static void rolloverY(View v) { ObjectAnimator yRollover = ObjectAnimator.ofFloat(v, "rotationY", 0f, 3600f); AnimatorSet set = new AnimatorSet(); set.play(yRollover); yRollover.start();//from ww w . j a va2s . com }
From source file:com.crust87.centercropvideoviewsample.LoadImageTask.java
private static void fadeInView(View view) { ObjectAnimator fadeIn = ObjectAnimator.ofFloat(view, "alpha", 0.0f, 1f); fadeIn.setDuration(500);/*from ww w . j ava 2s. c o m*/ AnimatorSet fadeSet = new AnimatorSet(); fadeSet.play(fadeIn); fadeSet.start(); }
From source file:com.microsoft.azure.engagement.ProductDiscountActivity.java
/** * Method that animates a view//from w w w. ja v a 2s . com * * @param view The view to animate * @param objectAnimator The objectAnimator to play * @param isVisible The visibility of the view at the end of the animation */ public static final void performAnimation(final View view, ObjectAnimator objectAnimator, final boolean isVisible) { view.setVisibility(View.VISIBLE); objectAnimator.setDuration(300); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(objectAnimator); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE); } }); animatorSet.start(); }
From source file:com.chromium.fontinstaller.util.ViewUtils.java
public static void reveal(Activity activity, View view, View sourceView, int colorRes) { if (activity == null || view == null || sourceView == null) return;//from w w w . j av a 2s . c o m if (isLollipop()) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView() .getOverlay(); final Rect displayRect = new Rect(); view.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(activity); revealView.setTop(displayRect.top); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes)); groupOverlay.add(revealView); final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); try { final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime)); alphaAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in)); view.setVisibility(View.VISIBLE); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); } }); animatorSet.start(); } catch (IllegalStateException e) { Timber.i("View is detached - not animating"); } } else { view.setVisibility(View.VISIBLE); } }
From source file:Main.java
public static void animateColorChange(View view, int fromColor, int toColor, int duration, Animator.AnimatorListener listener) { if (view.getWindowToken() == null) { return;/*from www . j a v a 2s . co m*/ } AnimatorSet animation = new AnimatorSet(); ObjectAnimator colorAnimator = ObjectAnimator.ofInt(view, COLOR_PROPERTY, fromColor, toColor); colorAnimator.setEvaluator(new ArgbEvaluator()); colorAnimator.setDuration(duration); if (listener != null) animation.addListener(listener); animation.play(colorAnimator); animation.start(); }
From source file:Main.java
@NonNull private static AnimatorSet createDisappearAnim(View btnPanel, View recyclerView, View locationTxt, View headline) {// w w w.j ava 2 s . c om AnimatorSet animAll = new AnimatorSet(); Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 1, 0); Animator anim1_2 = ObjectAnimator.ofFloat(btnPanel, View.ALPHA, 1, 0); Animator anim1_3 = ObjectAnimator.ofFloat(btnPanel, View.ALPHA, 1, 0); Animator anim1_4 = ObjectAnimator.ofFloat(recyclerView, View.ALPHA, 1, 0); setBatchTiming(400, 0, anim1_1, anim1_2, anim1_3, anim1_4, anim1_4); animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4); Interpolator interpolator2 = new DecelerateInterpolator(); Animator anim2_1 = ObjectAnimator.ofFloat(locationTxt, View.ALPHA, 1, 0); Animator anim2_2 = ObjectAnimator.ofFloat(locationTxt, View.SCALE_X, 1f, 2f); Animator anim2_3 = ObjectAnimator.ofFloat(locationTxt, View.SCALE_Y, 1f, 2f); anim2_1.setInterpolator(interpolator2); anim2_2.setInterpolator(interpolator2); anim2_3.setInterpolator(interpolator2); setBatchTiming(800, 0, anim2_1, anim2_2, anim2_3); animAll.play(anim2_1).with(anim2_2).with(anim2_3).after(anim1_1); return animAll; }
From source file:Main.java
@NonNull private static AnimatorSet createRevealAnimation(View headline, View btnPanel, View recyclerView, View locationTxt) {/*www.ja va 2 s . co m*/ AnimatorSet animAll = new AnimatorSet(); Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 0, 1, 1); Animator anim1_2 = ObjectAnimator.ofFloat(headline, View.TRANSLATION_Y, -headline.getBottom(), 60, 0); Animator anim1_3 = ObjectAnimator.ofFloat(headline, View.SCALE_X, 0.1f, 0.475f, 1); Animator anim1_4 = ObjectAnimator.ofFloat(headline, View.SCALE_Y, 0.1f, 0.475f, 1); setBatchTiming(1000, 0, anim1_1, anim1_2, anim1_3, anim1_4); animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4); Animator anim2_1 = ObjectAnimator.ofFloat(btnPanel, View.ALPHA, 0, 1); Animator anim2_2 = ObjectAnimator.ofFloat(btnPanel, View.TRANSLATION_Y, btnPanel.getHeight() / 4, 0); setBatchTiming(800, 0, anim2_1, anim2_2); animAll.play(anim2_1).with(anim2_2).after(anim1_1); Animator anim3_1 = ObjectAnimator.ofFloat(recyclerView, View.ALPHA, 0, 1); Animator anim3_2 = ObjectAnimator.ofFloat(locationTxt, View.ALPHA, 0, 1); setBatchTiming(1800, 0, anim3_1, anim3_2); animAll.play(anim3_1).with(anim3_2).after(anim1_1); return animAll; }
From source file:Main.java
@NonNull private static AnimatorSet createRevealAnimation(View headline, View image, View startBtn, View pick1, View pick2) {//from w w w .j av a 2 s . c o m AnimatorSet animAll = new AnimatorSet(); Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 0, 1, 1); Animator anim1_2 = ObjectAnimator.ofFloat(headline, View.TRANSLATION_Y, -headline.getBottom(), 60, 0); Animator anim1_3 = ObjectAnimator.ofFloat(headline, View.SCALE_X, 0.1f, 0.475f, 1); Animator anim1_4 = ObjectAnimator.ofFloat(headline, View.SCALE_Y, 0.1f, 0.475f, 1); setBatchTiming(1000, 0, anim1_1, anim1_2, anim1_3, anim1_4); animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4); Animator anim2_1 = ObjectAnimator.ofFloat(image, View.ALPHA, 0, 1); Animator anim2_2 = ObjectAnimator.ofFloat(image, View.TRANSLATION_Y, image.getHeight() / 4, 0); setBatchTiming(800, 0, anim2_1, anim2_2); animAll.play(anim2_1).with(anim2_2).after(anim1_1); Animator anim3_1 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 0, 1); Animator anim3_2 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 0, 1); Animator anim3_3 = ObjectAnimator.ofFloat(pick1, View.ALPHA, 0, 1); Animator anim3_4 = ObjectAnimator.ofFloat(pick2, View.ALPHA, 0, 1); setBatchTiming(1800, 0, anim3_1, anim3_2, anim3_3, anim3_4); animAll.play(anim3_1).with(anim3_2).with(anim3_3).with(anim3_4).after(anim1_1); return animAll; }
From source file:Main.java
@NonNull private static AnimatorSet createDisappearAnim(View startBtn, View pick1, View pick2, View image, View headline) {/*from ww w. j ava 2 s . c o m*/ AnimatorSet animAll = new AnimatorSet(); Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 1, 0); Animator anim1_2 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 1, 0); Animator anim1_3 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 1, 0); Animator anim1_4 = ObjectAnimator.ofFloat(pick1, View.ALPHA, 1, 0); Animator anim1_5 = ObjectAnimator.ofFloat(pick2, View.ALPHA, 1, 0); setBatchTiming(400, 0, anim1_1, anim1_2, anim1_3, anim1_4, anim1_5); animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4).with(anim1_5); Interpolator interpolator2 = new DecelerateInterpolator(); Animator anim2_1 = ObjectAnimator.ofFloat(image, View.ALPHA, 1, 0); Animator anim2_2 = ObjectAnimator.ofFloat(image, View.SCALE_X, 1f, 2f); Animator anim2_3 = ObjectAnimator.ofFloat(image, View.SCALE_Y, 1f, 2f); anim2_1.setInterpolator(interpolator2); anim2_2.setInterpolator(interpolator2); anim2_3.setInterpolator(interpolator2); setBatchTiming(800, 0, anim2_1, anim2_2, anim2_3); animAll.play(anim2_1).with(anim2_2).with(anim2_3).after(anim1_1); return animAll; }
From source file:Main.java
public static void animateHeart(View view) { AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(view, "scaleY", 1.0f, 1.2f); imgScaleUpYAnim.setDuration(300);//from w ww . j a v a 2 s . c om ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(view, "scaleX", 1.0f, 1.2f); imgScaleUpXAnim.setDuration(300); ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(view, "scaleY", 1.2f, 1.0f); imgScaleDownYAnim.setDuration(300); imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR); ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(view, "scaleX", 1.2f, 1.0f); imgScaleDownXAnim.setDuration(300); animatorSet.playTogether(imgScaleUpXAnim, imgScaleUpYAnim); animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpXAnim); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.clearAnimation(); animatorSet.start(); } }); animatorSet.start(); }