Create click Animation - Android Animation

Android examples for Animation:Animation Creation

Description

Create click Animation

Demo Code


//package com.java2s;

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

import android.view.animation.ScaleAnimation;

public class Main {
    public static Animation clickAnimation(float scaleXY,
            long durationMillis) {
        AnimationSet set = new AnimationSet(true);
        set.addAnimation(getScaleAnimation(scaleXY, durationMillis));
        set.setDuration(durationMillis);
        return set;
    }//  w  w  w  .j  av  a 2s. c  o m

    public static Animation getScaleAnimation(float scaleXY,
            long durationMillis) {
        ScaleAnimation scale = new ScaleAnimation(1.0f, scaleXY, 1.0f,
                scaleXY, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        scale.setDuration(durationMillis);
        return scale;
    }
}

Related Tutorials