visibility Animation - Android Animation

Android examples for Animation:Animation Creation

Description

visibility 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 visibilityAnimation(final GameButton gameButton,
            final Context context) {
        AlphaAnimation animation = new AlphaAnimation(0f, 1f);
        animation.setDuration(ANIMATION_DURATION);
        gameButton.getButton().setBackground(
                context.getResources().getDrawable(
                        R.drawable.animation_appear_layout));
        gameButton.getButton().setVisibility(View.VISIBLE);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override//from www.  j a v a 2s . co  m
            public void onAnimationStart(Animation animation) {
            }

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

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        gameButton.getButton().startAnimation(animation);
    }
}

Related Tutorials