List of usage examples for android.animation ObjectAnimator ofFloat
public static <T> ObjectAnimator ofFloat(T target, Property<T, Float> xProperty, Property<T, Float> yProperty, Path path)
Path
using two properties. From source file:Main.java
public static Animator getAlphaAnimator(View view, boolean hideView) { float start = hideView ? 1 : 0; float end = hideView ? 0 : 1; view.setAlpha(start);/*from ww w .j ava 2s . c o m*/ ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, start, end); animator.setDuration(200); return animator; }
From source file:Main.java
public static void runFlipHorizonAnimation(@NonNull View view, long duration, final Runnable rWhenEnd) { view.setAlpha(0);//from ww w.j a va 2 s . c o m AnimatorSet set = new AnimatorSet(); ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(view, "rotationY", -180f, 0f); ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); set.setDuration(duration); set.playTogether(objectAnimator1, objectAnimator2); if (rWhenEnd != null) set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { rWhenEnd.run(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); }
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();/*from w ww .j a va2 s.c om*/ 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 animateHeart(View view) { AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(view, "scaleY", 1.0f, 1.2f); imgScaleUpYAnim.setDuration(300);/*from ww w .j av a 2 s. c o m*/ 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(); }
From source file:Main.java
public static void animateTextChange(final TextView view, @IdRes final int toText, final Runnable rWhenEnd) { ObjectAnimator alpha = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f); final ObjectAnimator restore = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f); alpha.setDuration(DURATION_SHORT);/*from ww w .ja va2s . c o m*/ alpha.setInterpolator(new AccelerateDecelerateInterpolator()); restore.setDuration(DURATION_SHORT); restore.setInterpolator(new AccelerateDecelerateInterpolator()); alpha.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { // Do nothing. } @SuppressWarnings("ResourceType") @Override public void onAnimationEnd(Animator animation) { view.setText(toText); restore.start(); } @SuppressWarnings("ResourceType") @Override public void onAnimationCancel(Animator animation) { view.setText(toText); } @Override public void onAnimationRepeat(Animator animation) { // Do nothing. } }); if (rWhenEnd != null) restore.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { rWhenEnd.run(); } @Override public void onAnimationCancel(Animator animation) { rWhenEnd.run(); } @Override public void onAnimationRepeat(Animator animation) { } }); alpha.start(); }
From source file:Main.java
/** * Fade Animation/* w w w.j a v a 2s. c om*/ * @param view View to be animated * @param fromAlpha initial alpha * @param toAlpha final alpha * @param duration animation duration in milliseconds * @return Animator Object */ @NonNull public static Animator fade(@NonNull final View view, float fromAlpha, float toAlpha, int duration) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, "alpha", fromAlpha, toAlpha); animator.setDuration(duration); return animator; }
From source file:Main.java
@NonNull private static AnimatorSet createDisappearAnim(View btnPanel, View recyclerView, View locationTxt, View headline) {/*from ww w . j av a 2 s.c o m*/ 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
/** * 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 *///from www . j a va 2 s. c o m 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 ava2 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 animAlpha(View view, float fromAlpha, float toAlpha, int duration, int delay) { Animator anim = ObjectAnimator.ofFloat(view, "alpha", fromAlpha, toAlpha).setDuration(duration); anim.setStartDelay(delay);//from w w w . j a va 2 s . co m anim.start(); }