Example usage for android.view.animation ScaleAnimation setStartOffset

List of usage examples for android.view.animation ScaleAnimation setStartOffset

Introduction

In this page you can find the example usage for android.view.animation ScaleAnimation setStartOffset.

Prototype

public void setStartOffset(long startOffset) 

Source Link

Document

When this animation should start relative to the start time.

Usage

From source file:Main.java

public static void shrinkToLeft(FragmentActivity activity, View view, AnimationListener listener) {

    DisplayMetrics displaymetrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int screenHeight = displaymetrics.heightPixels;
    int screenWidth = displaymetrics.widthPixels;

    AnimationSet animation = new AnimationSet(true);
    float pivotX = view.getWidth() / 2;
    float pivotY = view.getHeight() / 2;
    ScaleAnimation anim = new ScaleAnimation(1f, 0.8f, 1f, 0.8f, pivotX, pivotY);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(200);/*from www . j  a va2 s . co  m*/
    anim.setStartOffset(200);
    //anim.setFillAfter(true);
    animation.addAnimation(anim);

    TranslateAnimation animTrans = new TranslateAnimation(0.0f, (float) -(screenWidth - view.getWidth()), 0.0f,
            0.0f);
    anim.setInterpolator(new LinearInterpolator());
    animTrans.setDuration(400);
    //animTrans.setStartOffset(300);
    animation.addAnimation(animTrans);

    if (listener != null)
        animation.setAnimationListener(listener);

    view.startAnimation(animation);
}

From source file:Main.java

public static void enlargeToRight(FragmentActivity activity, View view, AnimationListener listener) {

    DisplayMetrics displaymetrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int screenHeight = displaymetrics.heightPixels;
    int screenWidth = displaymetrics.widthPixels;

    AnimationSet animation = new AnimationSet(true);
    float pivotX = view.getWidth() / 2;
    float pivotY = view.getHeight() / 2;
    ScaleAnimation anim = new ScaleAnimation(0.8f, 1f, 0.8f, 1f, pivotX, pivotY);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(200);//from  w w  w  . j  a  va 2  s . c om
    anim.setStartOffset(200);
    //anim.setFillAfter(true);
    animation.addAnimation(anim);

    TranslateAnimation animTrans = new TranslateAnimation(0.0f, (float) (screenWidth - view.getWidth()), 0.0f,
            0.0f);
    anim.setInterpolator(new LinearInterpolator());
    animTrans.setDuration(400);
    //animTrans.setStartOffset(300);
    animation.addAnimation(animTrans);

    if (listener != null)
        animation.setAnimationListener(listener);

    view.startAnimation(animation);
}

From source file:Main.java

public static AnimationSet RotateAndFadeInAnimation() {

    AlphaAnimation fade_in = new AlphaAnimation(0.2f, 1f);
    fade_in.setDuration(400);//from  w  ww .j  av a  2 s . co m
    fade_in.setStartOffset(0);
    fade_in.setFillAfter(true);

    ScaleAnimation expand = new ScaleAnimation(0.2f, 1, 0.2f, 1, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    expand.setDuration(500);
    expand.setStartOffset(0);
    expand.setFillAfter(true);

    RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    rotate.setDuration(500);
    rotate.setStartOffset(0);
    // rotate.setInterpolator(new LinearInterpolator());
    rotate.setFillAfter(true);

    AnimationSet Reload = new AnimationSet(true);
    Reload.addAnimation(fade_in);
    Reload.addAnimation(expand);
    Reload.addAnimation(rotate);
    Reload.setInterpolator(new DecelerateInterpolator(1.3f));
    return Reload;
}

From source file:Main.java

public static AnimationSet RotateAndFadeOutAnimation() {
    AlphaAnimation fade_out = new AlphaAnimation(1f, 0.2f);
    fade_out.setDuration(500);/*  www .j a v  a 2  s.c o m*/
    fade_out.setStartOffset(0);
    fade_out.setFillAfter(true);

    ScaleAnimation shrink = new ScaleAnimation(1f, 0.2f, 1f, 0.2f, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    shrink.setDuration(400);
    shrink.setStartOffset(0);
    shrink.setFillAfter(true);

    RotateAnimation rotate = new RotateAnimation(0.0f, 360f, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    rotate.setDuration(500);
    rotate.setStartOffset(0);
    rotate.setInterpolator(new LinearInterpolator());
    rotate.setFillAfter(true);

    AnimationSet Reload = new AnimationSet(true);
    Reload.addAnimation(fade_out);
    Reload.addAnimation(shrink);
    Reload.addAnimation(rotate);
    Reload.setInterpolator(new AccelerateInterpolator(1.1f));

    return Reload;
}

From source file:Main.java

/**
 * Helps to show views.//from w w  w  .ja  va 2s .c  om
 *
 * @param views             Views to show.
 * @param animationDuration Animation duration.
 * @param animationDelay    Animation delay.
 */
static void orderedShowViews(final List<View> views, long animationDuration, int animationDelay) {
    if (views != null) {
        for (int viewIndex = 0; viewIndex < views.size(); viewIndex++) {
            final View childView = views.get(viewIndex);
            childView.setVisibility(View.VISIBLE);
            final ScaleAnimation scaleAnimation = new ScaleAnimation(0, childView.getScaleX(), 0,
                    childView.getScaleY(), Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
            scaleAnimation.setInterpolator(new DecelerateInterpolator());
            scaleAnimation.setDuration(animationDuration);
            scaleAnimation.setStartOffset(viewIndex * animationDelay);
            childView.startAnimation(scaleAnimation);
        }
    }
}

From source file:Main.java

public static void popup(View view) {

    AnimationSet animation = new AnimationSet(true);
    float pivotX = view.getWidth() / 2;
    float pivotY = view.getHeight() / 2;
    ScaleAnimation anim = new ScaleAnimation(0f, 1.1f, 0f, 1.1f, pivotX, pivotY);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(300);/*from w w w  .j  a va  2  s. c  om*/
    animation.addAnimation(anim);

    anim = new ScaleAnimation(1.1f, 1f, 1.1f, 1f, pivotX, pivotY);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(100);
    anim.setStartOffset(300);
    animation.addAnimation(anim);

    view.startAnimation(animation);
}