List of usage examples for android.animation ObjectAnimator setDuration
@Override @NonNull public ObjectAnimator setDuration(long duration)
From source file:Main.java
public static void alphaHide(@NonNull final View view, final Runnable rWhenDone) { if (view.getWindowToken() == null) { if (rWhenDone != null) rWhenDone.run();/* w w w.j a va 2 s . co m*/ return; } ObjectAnimator alpha = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f); alpha.setDuration(DURATION_MID); alpha.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.INVISIBLE); if (rWhenDone != null) rWhenDone.run(); } @Override public void onAnimationCancel(Animator animation) { view.setVisibility(View.INVISIBLE); if (rWhenDone != null) rWhenDone.run(); } @Override public void onAnimationRepeat(Animator animation) { } }); alpha.start(); }
From source file:Main.java
public static void animateHeartButton(final View v) { AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator rotationAnim = ObjectAnimator.ofFloat(v, "rotation", 0f, 360f); rotationAnim.setDuration(300); rotationAnim.setInterpolator(ACCELERATE_INTERPOLATOR); ObjectAnimator bounceAnimX = ObjectAnimator.ofFloat(v, "scaleX", 0.2f, 1f); bounceAnimX.setDuration(300);//from www.ja v a 2 s . c om bounceAnimX.setInterpolator(OVERSHOOT_INTERPOLATOR); ObjectAnimator bounceAnimY = ObjectAnimator.ofFloat(v, "scaleY", 0.2f, 1f); bounceAnimY.setDuration(300); bounceAnimY.setInterpolator(OVERSHOOT_INTERPOLATOR); bounceAnimY.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { } }); animatorSet.play(bounceAnimX).with(bounceAnimY).after(rotationAnim); animatorSet.start(); }
From source file:Main.java
public static void showBackgroundColorAnimation(View view, int preColor, int currColor, int duration) { ObjectAnimator localObjectAnimator = ObjectAnimator.ofInt(view, "backgroundColor", new int[] { preColor, currColor }); localObjectAnimator.setDuration(duration); localObjectAnimator.setEvaluator(new ArgbEvaluator()); localObjectAnimator.start();//from w w w. j av a 2 s . c om }
From source file:Main.java
/** * Render an animator to pulsate a view in place. * @param labelToAnimate the view to pulsate. * @return The animator object. Use .start() to begin. *///from w w w. j a v a 2 s . c o m public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
From source file:Main.java
public static ObjectAnimator getChangeAnimator(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", oldLeft, left); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", oldTop, top); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", oldRight, right); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", oldBottom, bottom); ObjectAnimator changeAnimator = ObjectAnimator.ofPropertyValuesHolder((Object) view, pvhLeft, pvhTop, pvhRight, pvhBottom);//from ww w .ja va2 s. c o m changeAnimator.setDuration(600); return changeAnimator; }
From source file:Main.java
public static void doSimpleRefresh(Object view) { LinearInterpolator interpolator = new LinearInterpolator(); ObjectAnimator refreshAnimator = ObjectAnimator.ofFloat(view, "rotation", 0f, 360f); refreshAnimator.setInterpolator(interpolator); refreshAnimator.setDuration(300); refreshAnimator.setRepeatCount(3);/*from ww w . jav a2 s .co m*/ refreshAnimator.start(); }
From source file:Main.java
public static void doSimpleRefresh(Object view, int repeat) { LinearInterpolator interpolator = new LinearInterpolator(); ObjectAnimator refreshAnimator = ObjectAnimator.ofFloat(view, "rotation", 0f, 360f); refreshAnimator.setInterpolator(interpolator); refreshAnimator.setDuration(300); refreshAnimator.setRepeatCount(repeat); refreshAnimator.start();//ww w . jav a2 s .c o m }
From source file:Main.java
/** * Create fade in animation for appearing effect * * @param target target view for animating * @param durationInMilis animation duration * @param delayInMilis start animation in delay * @param listener listener of animation behaviour *//*w ww . j a va2 s. c om*/ public static void setFadeAppearEffect(View target, int durationInMilis, int delayInMilis, Animator.AnimatorListener listener) { ObjectAnimator alphaAnimation6 = ObjectAnimator.ofFloat(target, "alpha", 0.0F, 1.0F); alphaAnimation6.setStartDelay(delayInMilis); alphaAnimation6.setDuration(durationInMilis); if (listener != null) { alphaAnimation6.addListener(listener); } alphaAnimation6.start(); }
From source file:Main.java
/** * Create fade out animation for disappearing effect * * @param target target view for animating * @param durationInMilis animation duration * @param delayInMilis start animation in delay * @param listener listener of animation behaviour *//*w w w.j a v a 2 s.co m*/ public static void setFadeDisappearEffect(View target, int durationInMilis, int delayInMilis, Animator.AnimatorListener listener) { ObjectAnimator alphaAnimation6 = ObjectAnimator.ofFloat(target, "alpha", 1.0F, 0.0F); alphaAnimation6.setStartDelay(delayInMilis); alphaAnimation6.setDuration(durationInMilis); if (listener != null) { alphaAnimation6.addListener(listener); } alphaAnimation6.start(); }
From source file:Main.java
public static void spinOnceX(View view, int cameraDistance, int duration, boolean forward) { view.setCameraDistance(cameraDistance); ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotationX", 0.0f, forward ? 360.0f : -360.0f); animator.setRepeatMode(ObjectAnimator.REVERSE); animator.setDuration(duration); animator.start();/*from w w w . j av a 2s . c om*/ }