Scale small Then Big Animation - Android Animation

Android examples for Animation:Scale Animation

Description

Scale small Then Big Animation

Demo Code


//package com.java2s;

import android.view.View;

import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;

public class Main {
    public static void smallThenBig(View animationView,
            Animation.AnimationListener animationListener) {
        AnimationSet animationSet = new AnimationSet(true);
        ScaleAnimation smallAnimation = new ScaleAnimation(1f, (float) 0.8,
                1f, (float) 0.8, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        smallAnimation.setDuration(80);//ww  w .  jav a  2s  . com
        smallAnimation.setFillAfter(false);
        animationSet.addAnimation(smallAnimation);

        ScaleAnimation bigAnimation = new ScaleAnimation((float) 1.2, 1f,
                (float) 1.2, 1f, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        bigAnimation.setDuration(160);
        bigAnimation.setStartOffset(80);
        bigAnimation.setFillAfter(false);
        animationSet.addAnimation(bigAnimation);
        animationSet.setAnimationListener(animationListener);
        animationView.startAnimation(animationSet);
    }
}

Related Tutorials