Example usage for android.view View setScaleY

List of usage examples for android.view View setScaleY

Introduction

In this page you can find the example usage for android.view View setScaleY.

Prototype

public void setScaleY(float scaleY) 

Source Link

Document

Sets the amount that the view is scaled in Y around the pivot point, as a proportion of the view's unscaled width.

Usage

From source file:Main.java

private static void scaleInternal(final View view, int startScaleValue, int endScaleValue, int durationMs,
        int startDelay, AnimatorListenerAdapter listener, Interpolator interpolator) {
    view.setScaleX(startScaleValue);/* w  w  w . ja  v  a2 s . c  o  m*/
    view.setScaleY(startScaleValue);

    final ViewPropertyAnimator animator = view.animate();
    animator.cancel();

    animator.setInterpolator(interpolator).scaleX(endScaleValue).scaleY(endScaleValue).setListener(listener)
            .withLayer();

    if (durationMs != DEFAULT_DURATION) {
        animator.setDuration(durationMs);
    }
    animator.setStartDelay(startDelay);

    animator.start();
}

From source file:me.lizheng.deckview.helpers.DeckChildViewTransform.java

/**
 * Reset the transform on a view./*from w ww  . jav a  2  s . co m*/
 */
public static void reset(View v) {
    v.setTranslationX(0f);
    v.setTranslationY(0f);
    ViewCompat.setTranslationZ(v, 0f);
    v.setScaleX(1f);
    v.setScaleY(1f);
    v.setAlpha(1f);
}

From source file:com.erevacation.challenge.rxjavaanimator.ViewAnimatorCreator.java

private static ViewPropertyAnimator animateScaleDown(View view, int duration, int delay,
        TimeInterpolator interpolator) {
    view.setScaleX(1);/*from   w  ww. ja v a2s.co m*/
    view.setScaleY(1);
    ViewPropertyAnimator propertyAnimator = view.animate().scaleX(0).scaleY(0).setStartDelay(delay)
            .setDuration(duration);
    if (interpolator != null) {
        propertyAnimator.setInterpolator(interpolator);
    } else {
        propertyAnimator.setInterpolator(new FastOutLinearInInterpolator());
    }

    return propertyAnimator;
}

From source file:com.erevacation.challenge.rxjavaanimator.ViewAnimatorCreator.java

private static ViewPropertyAnimator animateScaleUp(View view, int duration, int delay,
        TimeInterpolator interpolator) {
    view.setScaleX(0);/*  w  w w .ja  v a2s  .c  om*/
    view.setScaleY(0);
    ViewPropertyAnimator propertyAnimator = view.animate().scaleX(1).scaleY(1).setStartDelay(delay)
            .setDuration(duration);

    if (interpolator != null) {
        propertyAnimator.setInterpolator(interpolator);
    } else {
        propertyAnimator.setInterpolator(new LinearOutSlowInInterpolator());
    }

    return propertyAnimator;
}

From source file:Main.java

public static void scale(final View view, float fromScale, float toScale, long duration,
        final Runnable whenDone) {
    if (Build.VERSION.SDK_INT >= 12) {
        if (duration == 0) {
            view.setScaleX(toScale);/*w ww. ja va  2  s .c o  m*/
            view.setScaleY(toScale);
            if (whenDone != null)
                whenDone.run();
        } else {
            ViewPropertyAnimator animation = view.animate().scaleX(toScale).scaleY(toScale)
                    .setDuration(duration);
            if (whenDone != null) {
                animation.setListener(new AnimatorListener() {
                    @Override
                    public void onAnimationCancel(Animator animation) {
                        whenDone.run();
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        whenDone.run();
                    }

                    @Override
                    public void onAnimationRepeat(Animator animation) {
                    }

                    @Override
                    public void onAnimationStart(Animator animation) {
                    }

                });
            }
            animation.start();
        }
    } else {
        ScaleAnimation scale = new ScaleAnimation(fromScale, toScale, fromScale, toScale,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        scale.setDuration(duration);
        scale.setFillEnabled(true);
        scale.setFillBefore(true);
        scale.setFillAfter(true);

        if (whenDone != null) {
            scale.setAnimationListener(new AnimationListener() {
                @Override
                public void onAnimationEnd(Animation animation) {
                    whenDone.run();
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }

                @Override
                public void onAnimationStart(Animation animation) {
                }

            });
        }
        addAnimation(view, scale);
    }
}

From source file:Main.java

public static void startScaleAnime(final View view, float newScale, Animator.AnimatorListener listener) {
    ValueAnimator anime = ValueAnimator.ofFloat(view.getScaleX(), newScale);
    anime.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override// w w  w  . jav  a 2  s  . c o m
        public void onAnimationUpdate(ValueAnimator animation) {
            float s = Float.parseFloat(animation.getAnimatedValue().toString());
            view.setScaleX(s);
            view.setScaleY(s);
        }
    });
    if (listener != null) {
        anime.addListener(listener);
    }
    anime.setDuration(mAnimeDuration);
    anime.start();
}

From source file:Main.java

/**
 * Scales in the view from scale of 0 to actual dimensions.
 * @param view The view to scale.//  www.java2s .  c  o  m
 * @param durationMs The duration of the scaling in milliseconds.
 * @param startDelayMs The delay to applying the scaling in milliseconds.
 */
public static void scaleIn(final View view, int durationMs, int startDelayMs) {
    AnimatorListenerAdapter listener = (new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            view.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            view.setScaleX(1);
            view.setScaleY(1);
        }
    });
    scaleInternal(view, 0 /* startScaleValue */, 1 /* endScaleValue */, durationMs, startDelayMs, listener,
            EASE_IN);
}

From source file:Main.java

/**
 * Scales out the view from actual dimensions to 0.
 * @param view The view to scale.//from   w  ww  . j  av  a 2 s .co m
 * @param durationMs The duration of the scaling in milliseconds.
 */
public static void scaleOut(final View view, int durationMs) {
    AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            view.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            view.setVisibility(View.GONE);
            view.setScaleX(0);
            view.setScaleY(0);
        }
    };

    scaleInternal(view, 1 /* startScaleValue */, 0 /* endScaleValue */, durationMs, NO_DELAY, listener,
            EASE_OUT);
}

From source file:com.facebook.react.uimanager.BaseViewManager.java

private static void resetTransformProperty(View view) {
    view.setTranslationX(PixelUtil.toPixelFromDIP(0));
    view.setTranslationY(PixelUtil.toPixelFromDIP(0));
    view.setRotation(0);/*from ww  w.  j  av a2 s .  c  om*/
    view.setRotationX(0);
    view.setRotationY(0);
    view.setScaleX(1);
    view.setScaleY(1);
    view.setCameraDistance(0);
}

From source file:Main.java

/**
 * Scales out the view from actual dimensions to 0.
 * @param view The view to scale.//  w  w  w.ja v  a 2  s  .  c o m
 * @param durationMs The duration of the scaling in milliseconds.
 */
public static void scaleOut(final View view, int durationMs) {
    AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            view.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            view.setVisibility(View.INVISIBLE);
            view.setScaleX(0);
            view.setScaleY(0);
        }
    };

    scaleInternal(view, 1 /* startScaleValue */, 0 /* endScaleValue */, durationMs, NO_DELAY, listener,
            EASE_OUT);
}