Example usage for android.animation ValueAnimator getAnimatedValue

List of usage examples for android.animation ValueAnimator getAnimatedValue

Introduction

In this page you can find the example usage for android.animation ValueAnimator getAnimatedValue.

Prototype

public Object getAnimatedValue() 

Source Link

Document

The most recent value calculated by this ValueAnimator when there is just one property being animated.

Usage

From source file:Main.java

public static void changeTextColor(final TextView textView, int fromColor, int toColor) {
    ValueAnimator changeTextColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    changeTextColorAnimation.setDuration(150);
    changeTextColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/* w w w .  j a  v a2 s  . c o  m*/
        public void onAnimationUpdate(ValueAnimator animator) {
            textView.setTextColor((Integer) animator.getAnimatedValue());
        }
    });
    changeTextColorAnimation.start();
}

From source file:Main.java

static void changeImageColorFilter(final ImageView image, int fromColor, int toColor) {
    ValueAnimator imageColorChangeAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    imageColorChangeAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//from  w  ww . j av  a  2s  . c  om
        public void onAnimationUpdate(ValueAnimator animator) {
            image.setColorFilter((Integer) animator.getAnimatedValue());
        }
    });
    imageColorChangeAnimation.setDuration(150);
    imageColorChangeAnimation.start();
}

From source file:Main.java

public static void backgroundColorChange(final View view, int fromColor, int toColor) {
    ValueAnimator imageColorChangeAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    imageColorChangeAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*from  w w  w .  j a va2 s .co  m*/
        public void onAnimationUpdate(ValueAnimator animator) {
            view.setBackgroundColor((Integer) animator.getAnimatedValue());
        }
    });
    imageColorChangeAnimation.setDuration(150);
    imageColorChangeAnimation.start();
}

From source file:Main.java

public static ValueAnimator slideAnimator(int start, int end, final View v) {
    ValueAnimator animator = ValueAnimator.ofInt(start, end);

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//from   w  w  w  . j  av  a  2s  . c om
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int value = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
            layoutParams.height = value;
            v.setLayoutParams(layoutParams);
        }
    });
    return animator;
}

From source file:Main.java

static void changeTextColor(final TextView textView, int fromColor, int toColor) {
    ValueAnimator changeTextColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    changeTextColorAnimation.setDuration(150);
    changeTextColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*from w  ww.  ja  va 2  s.  com*/
        public void onAnimationUpdate(ValueAnimator animator) {
            textView.setTextColor((Integer) animator.getAnimatedValue());
        }
    });
    changeTextColorAnimation.start();
}

From source file:Main.java

/**
 * Update text color with animation/*from w  w  w .j av  a 2 s  . 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

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   www.j  a v  a 2  s  .  c om
        public void onAnimationUpdate(ValueAnimator animator) {
            view.setBackgroundColor((Integer) animator.getAnimatedValue());
        }
    });
    imageColorChangeAnimation.setDuration(150);
    imageColorChangeAnimation.start();
}

From source file:Main.java

/**
 * Update text color with animation/*from w ww. ja va  2 s  .c  o m*/
 */
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();
}

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   w ww . ja v a  2  s . co 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);/*w  w w. j a v  a 2s  .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();
}