animate View And Hide - Android android.view.animation

Android examples for android.view.animation:Hide Animation

Description

animate View And Hide

Demo Code

import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;

public class Main{

    public static void animateViewAndHide(final View viewToAnimate) {
        Animation anim = new AlphaAnimation(1, 0);
        anim.setDuration(200);/*from   www.  j a  v  a 2s.  c  o  m*/
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                viewToAnimate.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        viewToAnimate.startAnimation(anim);
    }

}

Related Tutorials