Example usage for android.animation ValueAnimator setInterpolator

List of usage examples for android.animation ValueAnimator setInterpolator

Introduction

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

Prototype

@Override
public void setInterpolator(TimeInterpolator value) 

Source Link

Document

The time interpolator used in calculating the elapsed fraction of this animation.

Usage

From source file:Main.java

public static Animator createNoAnimationAnimator(View view) {
    ValueAnimator anim = ValueAnimator.ofInt(0, 1);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(1);//from   w  ww  . j  av  a  2 s  . c  o  m

    return anim;
}

From source file:Main.java

public static Animator animFlow(android.animation.ValueAnimator.AnimatorUpdateListener animatorupdatelistener) {
    ValueAnimator valueanimator = ValueAnimator.ofFloat(new float[] { 0.0F, 1.0F });
    valueanimator.setInterpolator(new AccelerateInterpolator());
    valueanimator.addUpdateListener(animatorupdatelistener);
    return valueanimator;
}

From source file:com.xujun.contralayout.utils.AnimatorUtil.java

public static void tanslation(final View view, float start, float end) {
    final ValueAnimator animator = ValueAnimator.ofFloat(start, end);
    view.setVisibility(View.VISIBLE);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*www .  j a va2  s .  c o m*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            Float value = (Float) animator.getAnimatedValue();
            Log.i(TAG, "tanslation: value=" + value);
            view.setTranslationY(value);
        }
    });
    animator.setDuration(200);
    animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
    animator.start();
}

From source file:com.xujun.contralayout.utils.AnimatorUtil.java

public static void show(final View view, int start, int end) {
    final int height = view.getHeight();
    final ValueAnimator animator = ValueAnimator.ofInt(start, end);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/* www.  j a v  a2s.  c o m*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int value = (Integer) animator.getAnimatedValue();
            Log.i(TAG, "onAnimationUpdate: value=" + value);
            view.setTop(value);
            view.setBottom(value + height);
        }
    });
    view.setVisibility(View.VISIBLE);
    animator.setDuration(200);
    animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
    animator.start();
}

From source file:com.xujun.contralayout.utils.AnimatorUtil.java

public static void showHeight(final View view, float start, float end) {
    final ValueAnimator animator = ValueAnimator.ofFloat(start, end);
    final ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*  ww  w .  j  a  v  a 2s  .  c o  m*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float value = (Float) animator.getAnimatedValue();
            layoutParams.height = (int) value;
            view.setLayoutParams(layoutParams);
            Log.i(TAG, "onAnimationUpdate: value=" + value);

        }
    });
    animator.setDuration(500);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();
}

From source file:org.hawkular.client.android.util.ViewTransformer.java

@UiThread
public void expand() {
    view.setVisibility(View.VISIBLE);

    ValueAnimator animator = ValueAnimator.ofInt(0, Views.measureHeight(view));
    animator.setInterpolator(new LinearOutSlowInInterpolator());
    animator.setDuration(Durations.MEDIUM);

    animator.addUpdateListener(this);

    animator.start();/*from  w w  w .ja v  a  2s . c om*/
}

From source file:org.hawkular.client.android.util.ViewTransformer.java

@UiThread
public void collapse() {
    ValueAnimator animator = ValueAnimator.ofInt(Views.measureHeight(view), 0);
    animator.setInterpolator(new LinearOutSlowInInterpolator());
    animator.setDuration(Durations.MEDIUM);

    animator.addUpdateListener(this);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override/*from   w ww . j a  va  2 s.  c  om*/
        public void onAnimationEnd(Animator animation) {
            view.setVisibility(View.GONE);
        }
    });

    animator.start();
}

From source file:org.sufficientlysecure.keychain.ui.BackupCodeFragment.java

private static void animateFlashText(final TextView[] textViews, int color1, int color2,
        boolean staySecondColor) {

    ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), color1, color2);
    anim.addUpdateListener(new AnimatorUpdateListener() {
        @Override//from  w ww  .  j a  v a 2s.  c  om
        public void onAnimationUpdate(ValueAnimator animator) {
            for (TextView textView : textViews) {
                textView.setTextColor((Integer) animator.getAnimatedValue());
            }
        }
    });
    anim.setRepeatMode(ValueAnimator.REVERSE);
    anim.setRepeatCount(staySecondColor ? 4 : 5);
    anim.setDuration(180);
    anim.setInterpolator(new AccelerateInterpolator());
    anim.start();

}

From source file:arun.com.chromer.browsing.article.util.ArticleScrollListener.java

private void animateBackgroundColor(int from, int to, Interpolator interpolator) {
    final ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(from, to);/*  ww w. ja v  a 2 s  .c o  m*/
    anim.setEvaluator(new ArgbEvaluator());
    anim.setInterpolator(interpolator);
    anim.addUpdateListener(valueAnimator -> {
        toolbar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
        statusBar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
    });
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            isUpdatingBackground = false;
        }
    });

    anim.setDuration(ANIMATION_DURATION);
    anim.start();
    isUpdatingBackground = true;
}

From source file:xyz.klinker.android.article.ArticleScrollListener.java

private void animateBackgroundColor(int from, int to, Interpolator interpolator) {
    final ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(from, to);/*from w  w  w  . ja v  a2  s .c  o  m*/
    anim.setEvaluator(new ArgbEvaluator());
    anim.setInterpolator(interpolator);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            toolbar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
            statusBar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue());
        }
    });
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            isUpdatingBackground = false;
        }
    });

    anim.setDuration(ANIMATION_DURATION);
    anim.start();
    isUpdatingBackground = true;
}