animate Scale In - Android Animation

Android examples for Animation:Scale Animation

Description

animate Scale In

Demo Code


//package com.java2s;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;

public class Main {
    public static void animateScaleIn(View view, long duration,
            Animator.AnimatorListener listener) {
        view.setScaleX(0f);//from   w w  w.  j a v a  2s . c om
        view.setScaleY(0f);
        view.setVisibility(View.VISIBLE);

        AnimatorSet scaleSet = new AnimatorSet();
        scaleSet.playTogether(
                ObjectAnimator.ofFloat(view, View.SCALE_X, 1f),
                ObjectAnimator.ofFloat(view, View.SCALE_Y, 1f));
        scaleSet.setInterpolator(new AccelerateDecelerateInterpolator());
        scaleSet.setDuration(duration);
        if (listener != null) {
            scaleSet.addListener(listener);
        }
        scaleSet.start();
        //return scaleSet;
    }
}

Related Tutorials