Example usage for android.animation ObjectAnimator ofFloat

List of usage examples for android.animation ObjectAnimator ofFloat

Introduction

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

Prototype

public static <T> ObjectAnimator ofFloat(T target, Property<T, Float> xProperty, Property<T, Float> yProperty,
        Path path) 

Source Link

Document

Constructs and returns an ObjectAnimator that animates coordinates along a Path using two properties.

Usage

From source file:Main.java

public static Animator createXTransition(View view, boolean enter) {
    ObjectAnimator x;/*  w  w  w  .j a  v a2s  .c  om*/
    ObjectAnimator y;
    if (enter) {
        x = ObjectAnimator.ofFloat(view, "translationX", 1f, 0f);
        y = ObjectAnimator.ofFloat(view, "translationY", 1f, 0f);
    } else {
        x = ObjectAnimator.ofFloat(view, "translationX", 0f, -1f);
        y = ObjectAnimator.ofFloat(view, "translationY", 0f, -1f);
    }

    AnimatorSet set = new AnimatorSet();
    set.playTogether(x, y);
    return set;
}

From source file:Main.java

public static ObjectAnimator alfaDisappear(View v) {
    return ObjectAnimator.ofFloat(v, "alpha", 1, 0);
}

From source file:Main.java

public static void animShow(View v, int duration, float from, float to) {
    if (v.getVisibility() == View.GONE) {
        v.setVisibility(View.VISIBLE);
    }//  www  .  j  a v a 2s.  c  o m
    v.clearAnimation();
    ObjectAnimator.ofFloat(v, "alpha", from, to).setDuration(duration).start();

}

From source file:Main.java

public static void alphaShow(@NonNull final View view) {
    if (view.getWindowToken() == null)
        return;//from  w  w  w. j av a  2 s  .c  om
    view.setVisibility(View.VISIBLE);
    ObjectAnimator alpha = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
    alpha.setDuration(DURATION_MID);
    alpha.start();
}

From source file:Main.java

public static void animateSpinIn(View view, long duration, Animator.AnimatorListener listener) {
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(duration);/*from ww w  .ja va  2 s . c o m*/
    animatorSet.playTogether(ObjectAnimator.ofFloat(view, "rotation", -200, 0),
            ObjectAnimator.ofFloat(view, "alpha", 0, 1));
    animatorSet.start();
}

From source file:Main.java

public static void animRotate(View view, float fromDegrees, float toDegrees, int duration) {
    ObjectAnimator.ofFloat(view, "rotation", fromDegrees, toDegrees).setDuration(duration).start();
}

From source file:Main.java

public static void animScale(View view, float fromX, float toX, float fromY, float toY, int duration) {
    ObjectAnimator.ofFloat(view, "scaleX", fromX, toX).setDuration(duration).start();
    ObjectAnimator.ofFloat(view, "scaleY", fromY, toY).setDuration(duration).start();
}

From source file:Main.java

public static void animAlpha(View view, float fromAlpha, float toAlpha, int duration) {
    ObjectAnimator.ofFloat(view, "alpha", fromAlpha, toAlpha).setDuration(duration).start();
}

From source file:Main.java

private static void initAnim() {

    animatorSet = new AnimatorSet();
    animatorSet.setDuration(500);/*from  www  .j  a va2s.  c om*/

    ObjectAnimator x = ObjectAnimator.ofFloat(text, "scaleX", 0.3f, 1f);
    ObjectAnimator y = ObjectAnimator.ofFloat(text, "scaleY", 0.3f, 1f);
    ObjectAnimator a = ObjectAnimator.ofFloat(text, "alpha", 0.3f, 1f);

    animatorSet.play(x).with(y).with(a);
    animatorSet.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
            isAiming = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            isAiming = false;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            isAiming = false;
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
            isAiming = true;
        }
    });
}

From source file:Main.java

public static void animHide(final View v, int duration, float from, float to, final boolean gone) {
    v.clearAnimation();//w  w  w.  j a  v a2  s  .com
    ObjectAnimator anim = ObjectAnimator.ofFloat(v, "alpha", from, to).setDuration(duration);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (gone) {
                v.setVisibility(View.GONE);
            }
        }
    });
    anim.start();
}