List of usage examples for android.animation ValueAnimator addUpdateListener
public void addUpdateListener(AnimatorUpdateListener listener)
From source file:Main.java
static void changeViewBackgroundColor(final View view, int fromColor, int toColor) { ValueAnimator imageColorChangeAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor); imageColorChangeAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w ww . j a va 2 s . co m*/ public void onAnimationUpdate(ValueAnimator animator) { view.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); imageColorChangeAnimation.setDuration(150); imageColorChangeAnimation.start(); }
From source file:Main.java
static void changeRightPadding(final View view, int fromPadding, int toPadding) { ValueAnimator animator = ValueAnimator.ofFloat(fromPadding, toPadding); animator.setDuration(150);/*from ww w. j a va 2s. c o m*/ animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedValue = (float) valueAnimator.getAnimatedValue(); view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), (int) animatedValue, view.getPaddingBottom()); } }); animator.start(); }
From source file:Main.java
static void changeViewTopPadding(final View view, int fromPadding, int toPadding) { ValueAnimator animator = ValueAnimator.ofFloat(fromPadding, toPadding); animator.setDuration(150);//from w w w. j a v a 2 s.c o m animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedValue = (float) valueAnimator.getAnimatedValue(); view.setPadding(view.getPaddingLeft(), (int) animatedValue, view.getPaddingRight(), view.getPaddingBottom()); } }); animator.start(); }
From source file:Main.java
static void changeViewLeftPadding(final View view, int fromMargin, int toMargin) { ValueAnimator animator = ValueAnimator.ofFloat(fromMargin, toMargin); animator.setDuration(3000);//ww w . j a va 2 s .c o m animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedValue = (float) valueAnimator.getAnimatedValue(); view.setPadding((int) animatedValue, view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom()); view.requestLayout(); } }); animator.start(); }
From source file:Main.java
private static Animator createFade(final View targetView, int startAlpha, int endAlpha) { ValueAnimator a = ValueAnimator.ofFloat(startAlpha, endAlpha); a.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override// www . j a v a 2 s .c o m public void onAnimationUpdate(ValueAnimator valueAnimator) { targetView.setAlpha((float) valueAnimator.getAnimatedValue()); } }); return a; }
From source file:Main.java
public static void changeTextSize(final TextView textView, float from, float to) { ValueAnimator textSizeChangeAnimator = ValueAnimator.ofFloat(from, to); textSizeChangeAnimator.setDuration(150); textSizeChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w w w . ja v a2 s . com public void onAnimationUpdate(ValueAnimator valueAnimator) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) valueAnimator.getAnimatedValue()); } }); textSizeChangeAnimator.start(); }
From source file:Main.java
static void changeTextSize(final TextView textView, float from, float to) { ValueAnimator textSizeChangeAnimator = ValueAnimator.ofFloat(from, to); textSizeChangeAnimator.setDuration(150); textSizeChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override// w w w . j av a 2 s . c o m public void onAnimationUpdate(ValueAnimator valueAnimator) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, (float) valueAnimator.getAnimatedValue()); } }); textSizeChangeAnimator.start(); }
From source file:Main.java
public static void dimBackground(final float from, final float to, Activity context) { final Window window = context.getWindow(); ValueAnimator valueAnimator = ValueAnimator.ofFloat(from, to); valueAnimator.setDuration(500);//from w w w . j a v a2 s . co m valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { WindowManager.LayoutParams params = window.getAttributes(); params.alpha = (Float) animation.getAnimatedValue(); window.setAttributes(params); } }); valueAnimator.start(); }
From source file:Main.java
/** * Update text color with animation/*w w w. j a va2s.co m*/ */ public static void updateTextColor(final TextView textView, int fromColor, int toColor) { ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor); colorAnimation.setDuration(150); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { textView.setTextColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.start(); }
From source file:Main.java
/** * Update text color with animation/* www . j a v a 2s.c om*/ */ public static void updateViewBackgroundColor(final View view, int fromColor, int toColor) { ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor); colorAnimation.setDuration(150); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { view.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.start(); }