Example usage for android.animation ObjectAnimator setInterpolator

List of usage examples for android.animation ObjectAnimator setInterpolator

Introduction

In this page you can find the example usage for android.animation ObjectAnimator 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 createFadeOutAnimator(View view) {
    ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(250);/*from www.j a  va 2s . co  m*/

    return anim;
}

From source file:Main.java

public static Animator createFadeInAnimator(View view) {
    ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(250);// www .  jav a 2 s  .com

    return anim;
}

From source file:Main.java

public static void makeSnake(View v) {
    ObjectAnimator snake = ObjectAnimator.ofFloat(v, "translationX", 0, 10).setDuration(300);
    snake.setInterpolator(new CycleInterpolator(2));
    snake.start();/*  w w  w  . j a  v  a 2  s.  c  om*/
}

From source file:Main.java

public static void slideFromLeftToRight(View view) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, "X", -2000, 0).setDuration(1000);

    animator.setInterpolator(new LinearInterpolator());

    animator.start();/*from w  ww  .j a  v a  2 s . c  o  m*/
}

From source file:Main.java

public static void doSimpleRefresh(Object view) {
    LinearInterpolator interpolator = new LinearInterpolator();
    ObjectAnimator refreshAnimator = ObjectAnimator.ofFloat(view, "rotation", 0f, 360f);
    refreshAnimator.setInterpolator(interpolator);
    refreshAnimator.setDuration(300);/*  w w  w. j  a  v  a  2  s  .c o m*/
    refreshAnimator.setRepeatCount(3);
    refreshAnimator.start();
}

From source file:Main.java

public static void doSimpleRefresh(Object view, int repeat) {
    LinearInterpolator interpolator = new LinearInterpolator();
    ObjectAnimator refreshAnimator = ObjectAnimator.ofFloat(view, "rotation", 0f, 360f);
    refreshAnimator.setInterpolator(interpolator);
    refreshAnimator.setDuration(300);/*  w w  w.  j  a  v  a 2s .  c  o m*/
    refreshAnimator.setRepeatCount(repeat);
    refreshAnimator.start();
}

From source file:Main.java

public static Animator animFadeIn(View view) {
    ObjectAnimator objectanimator = ObjectAnimator.ofFloat(view, "alpha", new float[] { 0.3F, 1.0F });
    objectanimator.setInterpolator(new AccelerateInterpolator());
    return objectanimator;
}

From source file:Main.java

public static void startRotateAnimation(View v, int duration) {
    ObjectAnimator oa = ObjectAnimator.ofFloat(v, "rotation", 0f, 360f);
    oa.setDuration(duration);//from w w  w.  ja  va2  s  .  c o m
    oa.setInterpolator(null);
    oa.setRepeatCount(ValueAnimator.INFINITE);
    oa.start();
}

From source file:Main.java

/**
 * This method creates an Object Animator based on the targeted view, the property to be
 * animated and the initial value and final value
 *
 * @param view// w  w w  .j  a  va  2  s .  c om
 *         Target view
 * @param property
 *         Property to be animated
 * @param init
 *         Initial value
 * @param end
 *         Final value
 * @param duration
 *         Animation duration
 *
 * @return ObjectAnimator with the given animated property
 */
@NonNull
public static ObjectAnimator createObjectAnimator(View view, String property, float init, float end,
        long duration) {
    ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(view, property, init, end);
    scaleXAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    scaleXAnimation.setDuration(duration);
    return scaleXAnimation;
}

From source file:Main.java

public static void arrowDownAnim(View view) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotation", 180f, 0f);
    animator.setDuration(400);//from   w  w  w  .j  a va 2 s.c o m
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.start();
}