invisibility Animation - Android Animation

Android examples for Animation:Animation Creation

Description

invisibility Animation

Demo Code


import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.TextView;

public class Main{
    private static final Long ANIMATION_DURATION = 700L;
    public static void invisibilityAnimation(final GameButton gameButton,
            final Context context) {
        AlphaAnimation animation = new AlphaAnimation(1f, 0f);
        animation.setDuration(ANIMATION_DURATION);
        gameButton.getButton().setBackground(
                context.getResources().getDrawable(
                        R.drawable.animation_disappear_layout));
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override//  www .ja v a 2 s .com
            public void onAnimationStart(Animation animation) {
                gameButton.getButton().setEnabled(false);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                gameButton.getButton().setBackground(
                        context.getResources().getDrawable(
                                R.drawable.background_normal));
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        gameButton.getButton().startAnimation(animation);
        gameButton.getButton().setVisibility(View.INVISIBLE);
    }
}

Related Tutorials