Search in sources :

Example 31 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project ahbottomnavigation by aurelhubert.

the class AHHelper method updateDrawableColor.

/**
	 * Update image view color with animation
	 */
public static void updateDrawableColor(final Context context, final Drawable drawable, final ImageView imageView, @ColorInt int fromColor, @ColorInt int toColor, final boolean forceTint) {
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), fromColor, toColor);
    colorAnimation.setDuration(150);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            imageView.setImageDrawable(AHHelper.getTintDrawable(drawable, (Integer) animator.getAnimatedValue(), forceTint));
            imageView.requestLayout();
        }
    });
    colorAnimation.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 32 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project ahbottomnavigation by aurelhubert.

the class AHHelper method updateTextColor.

/**
	 * Update text color with animation
	 */
public static void updateTextColor(final TextView textView, @ColorInt int fromColor, @ColorInt 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();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 33 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project MaterialViewPager by florent37.

the class MaterialViewPagerAnimator method setColor.

/**
     * Change the color of the statusbackground, toolbar, toolbarlayout and pagertitlestrip
     * With a color transition animation
     *
     * @param color    the final color
     * @param duration the transition color animation duration
     */
void setColor(int color, int duration) {
    final ValueAnimator colorAnim = ObjectAnimator.ofInt(mHeader.headerBackground, "backgroundColor", settings.color, color);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.setDuration(duration);
    colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            final int animatedValue = (Integer) animation.getAnimatedValue();
            int colorAlpha = colorWithAlpha(animatedValue, lastPercent);
            mHeader.headerBackground.setBackgroundColor(colorAlpha);
            mHeader.statusBackground.setBackgroundColor(colorAlpha);
            mHeader.toolbar.setBackgroundColor(colorAlpha);
            mHeader.toolbarLayoutBackground.setBackgroundColor(colorAlpha);
            mHeader.mPagerSlidingTabStrip.setBackgroundColor(colorAlpha);
            //set the new color as MaterialViewPager's color
            settings.color = animatedValue;
        }
    });
    colorAnim.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 34 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Depth-LIB-Android- by danielzeller.

the class ParticleSystem method setColors.

public void setColors(int startColor, int endColor) {
    this.startColor = startColor;
    this.endColor = endColor;
    color = ValueAnimator.ofObject(new ArgbEvaluator(), startColor, endColor, Color.TRANSPARENT).setDuration(DURATION);
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator)

Example 35 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project ENViews by codeestX.

the class ENScrollView method unSelect.

public void unSelect() {
    if (mCurrentState == STATE_UNSELECT) {
        return;
    }
    mCurrentState = STATE_UNSELECT;
    ValueAnimator valueAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), mLineColor, mBgLineColor);
    valueAnimator.setDuration(mDuration);
    valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mFraction = 1 - valueAnimator.getAnimatedFraction();
            mCurrentColor = (int) valueAnimator.getAnimatedValue();
            invalidate();
        }
    });
    if (!valueAnimator.isRunning()) {
        valueAnimator.start();
    }
    valueAnimator.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) ValueAnimator(android.animation.ValueAnimator)

Aggregations

ArgbEvaluator (android.animation.ArgbEvaluator)61 ValueAnimator (android.animation.ValueAnimator)30 ObjectAnimator (android.animation.ObjectAnimator)18 Animator (android.animation.Animator)10 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)7 TargetApi (android.annotation.TargetApi)6 View (android.view.View)6 Paint (android.graphics.Paint)5 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)4 TextView (android.widget.TextView)4 PropertyValuesHolder (android.animation.PropertyValuesHolder)3 SuppressLint (android.annotation.SuppressLint)3 ViewGroup (android.view.ViewGroup)3 AnimatorListener (android.animation.Animator.AnimatorListener)2 AnimatorSet (android.animation.AnimatorSet)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 Toolbar (android.support.v7.widget.Toolbar)2