Example usage for android.animation ArgbEvaluator ArgbEvaluator

List of usage examples for android.animation ArgbEvaluator ArgbEvaluator

Introduction

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

Prototype

ArgbEvaluator

Source Link

Usage

From source file:Main.java

public static int interpolate(float percent, int color1, int color2) {
    return (int) new ArgbEvaluator().evaluate(percent, color1, color2);
}

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

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  av a  2 s .  com
        public void onAnimationUpdate(ValueAnimator animator) {
            textView.setTextColor((Integer) animator.getAnimatedValue());
        }
    });
    changeTextColorAnimation.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 w ww  .j  a  v a2 s .c  o m
        public void onAnimationUpdate(ValueAnimator animator) {
            view.setBackgroundColor((Integer) animator.getAnimatedValue());
        }
    });
    imageColorChangeAnimation.setDuration(150);
    imageColorChangeAnimation.start();
}

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  www .  j a  v a2s .co 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   www  . ja  va  2s.  c o m
        public void onAnimationUpdate(ValueAnimator animator) {
            image.setColorFilter((Integer) animator.getAnimatedValue());
        }
    });
    imageColorChangeAnimation.setDuration(150);
    imageColorChangeAnimation.start();
}

From source file:Main.java

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

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

public static void showBackgroundColorAnimation(View view, int preColor, int currColor, int duration) {
    ObjectAnimator animator = ObjectAnimator.ofInt(view, "backgroundColor", new int[] { preColor, currColor });
    animator.setDuration(duration);/*from  w  ww.  ja va2s .  c  o  m*/
    animator.setEvaluator(new ArgbEvaluator());
    animator.start();
}

From source file:Main.java

public static void showCardBackgroundColorAnimation(View view, int preColor, int currColor, int duration) {
    ObjectAnimator animator = ObjectAnimator.ofInt(view, "cardBackgroundColor",
            new int[] { preColor, currColor });
    animator.setDuration(duration);//w w w . j  a  va  2  s . co m
    animator.setEvaluator(new ArgbEvaluator());
    animator.start();
}