Example usage for android.view.animation ScaleAnimation setFillAfter

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

Introduction

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

Prototype

public void setFillAfter(boolean fillAfter) 

Source Link

Document

If fillAfter is true, the transformation that this animation performed will persist when it is finished.

Usage

From source file:Main.java

private static void scaleDownAni(View v) {
    /*if(scaleDownAni == null){
       scaleDownAni = new ScaleAnimation(1.0f, SCALE_DOWN_VALUE, 1.0f, SCALE_DOWN_VALUE, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
       scaleDownAni.setDuration(SCALE_ANI_DURATION);
       scaleDownAni.setFillAfter(true);//from ww  w  .  j  av  a  2  s. c  om
    }*/

    ScaleAnimation scaleDownAni = new ScaleAnimation(1.0f, SCALE_DOWN_VALUE, 1.0f, SCALE_DOWN_VALUE,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scaleDownAni.setDuration(SCALE_ANI_DURATION);
    scaleDownAni.setFillAfter(true);

    //v.startAnimation(scaleDownAni);
    //v.setAnimation(scaleDownAni);
    //scaleDownAni.startNow();
    v.startAnimation(scaleDownAni);

    /*v.animate().scaleX(SCALE_DOWN_VALUE);
    v.animate().scaleY(SCALE_DOWN_VALUE);
    v.animate().setDuration(SCALE_ANI_DURATION);
    v.animate().start();*/

    //v.setScaleX(SCALE_DOWN_VALUE);
    //v.setScaleY(SCALE_DOWN_VALUE);
}

From source file:Main.java

public static void setOnTouchScaleAnimation(View targetView, final float scaleX, final float scaleY) {
    targetView.setOnTouchListener(new View.OnTouchListener() {
        @Override/*w w  w . j a  va  2  s .c om*/
        public boolean onTouch(View v, MotionEvent event) {
            final int action = event.getAction();
            switch (action) {
            case MotionEvent.ACTION_DOWN: {
                ScaleAnimation anim = new ScaleAnimation(1.0f, scaleX, 1.0f, scaleY, v.getWidth() / 2,
                        v.getHeight() / 2);
                anim.setDuration(60);
                anim.setFillEnabled(true);
                anim.setFillAfter(true);
                v.startAnimation(anim);
                break;
            }
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP: {
                ScaleAnimation anim = new ScaleAnimation(scaleX, 1.0f, scaleY, 1.0f, v.getWidth() / 2,
                        v.getHeight() / 2);
                anim.setDuration(100);
                v.startAnimation(anim);
                break;
            }
            }
            return false;
        }
    });
}

From source file:Main.java

/**
 * push View ScaleAnimation/*from w  w  w .j a v a 2  s .co m*/
 *
 * @param targetView TargetView
 * @param action     MotionEventAction
 * @param scaleX
 * @param scaleY
 */
private static void pushScale(View targetView, int action, float scaleX, float scaleY) {
    if (action == MotionEvent.ACTION_DOWN) {
        // Touch Down
        ScaleAnimation anim = new ScaleAnimation(1.0f, scaleX, 1.0f, scaleY, targetView.getWidth() / 2,
                targetView.getHeight() / 2);
        anim.setDuration(DURATION);
        anim.setFillEnabled(true);
        anim.setFillAfter(true);
        targetView.startAnimation(anim);
    } else if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
        // Touch Up
        ScaleAnimation anim = new ScaleAnimation(scaleX, 1.0f, scaleY, 1.0f, targetView.getWidth() / 2,
                targetView.getHeight() / 2);
        anim.setDuration(DURATION);
        anim.setFillEnabled(true);
        anim.setFillAfter(true);
        targetView.startAnimation(anim);
    }
}

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);//  ww  w .  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:com.silentcircle.common.util.ViewUtil.java

public static void scaleToInvisible(View view) {
    ScaleAnimation animate = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animate.setDuration(100);// w  w w . jav a2s  .  c  om
    animate.setFillAfter(true);
    view.startAnimation(animate);
    view.setVisibility(View.GONE);
}

From source file:com.silentcircle.common.util.ViewUtil.java

public static void scaleToVisible(View view) {
    ScaleAnimation animate = new ScaleAnimation(0.0f, 1.0f, 0.5f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animate.setDuration(100);//from  ww w  . ja  v a 2  s .c  om
    animate.setFillAfter(true);
    view.startAnimation(animate);
    view.setVisibility(View.VISIBLE);
}

From source file:zjut.soft.finalwork.fragment.RightFragment.java

public void plannerScaleAction() {
    ScaleAnimation scaleanim1 = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    scaleanim1.setDuration(1500);/* ww w.j a  v  a  2s  .c  o m*/
    scaleanim1.setFillAfter(true);
    scaleanim1.setRepeatCount(Animation.INFINITE);
    scaleanim1.setRepeatMode(Animation.REVERSE);
    scaleanim1.setInterpolator(new AccelerateDecelerateInterpolator());

    plannerIV.setAnimation(scaleanim1);
    scaleanim1.startNow();
}

From source file:quickbeer.android.next.views.ProgressIndicatorBar.java

private void animateToProgress(float progress) {
    Log.v(TAG, "animateToProgress(" + progress + ")");

    float newScale = (getWidth() * progress / progressBarWidth) + 1;

    ScaleAnimation animation = new ScaleAnimation(1, newScale, progressBar.getHeight(),
            progressBar.getHeight());//  w ww . ja v  a 2s  . c  om
    animation.setDuration(ANIMATION_PROGRESS_DURATION);
    animation.setFillAfter(true);

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}

From source file:quickbeer.android.next.views.ProgressIndicatorBar.java

private void animateToEnd() {
    Log.v(TAG, "animateToEnd()");

    if (progressBar.getAnimation() == null) {
        // Non-active progress bar doesn't need end animation
        return;//from  w  w  w.  java 2  s. c o m
    }

    ScaleAnimation animation = new ScaleAnimation(1, (getWidth() / progressBarWidth) + 1,
            progressBar.getHeight(), progressBar.getHeight());
    animation.setDuration(ANIMATION_END_SCALE_DURATION);
    animation.setFillAfter(true);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            animateToHidden();
        }
    });

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}

From source file:quickbeer.android.views.ProgressIndicatorBar.java

private void animateToProgress(float progress) {
    Timber.v("animateToProgress(%s)", progress);
    checkNotNull(progressBar);/*  w  w w .j a  va  2s .  c  om*/

    float newScale = (getWidth() * progress / progressBarWidth) + 1;

    Timber.v("animate scale %s -> %s", barScale, newScale);

    ScaleAnimation animation = new ScaleAnimation(barScale, newScale, progressBar.getHeight(),
            progressBar.getHeight());
    animation.setDuration(ANIMATION_PROGRESS_DURATION);
    animation.setFillAfter(true);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            barScale = newScale;
            applyNextStatus();
        }
    });

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}