hide Slide From Top - Android android.view.animation

Android examples for android.view.animation:slide Animation

Description

hide Slide From Top

Demo Code

import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LayoutAnimationController;
import android.view.animation.TranslateAnimation;

public class Main{

    public static void hideSlideFromTop(final ViewGroup panel) {
        Animation slide = new TranslateAnimation(
                Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, -1.0f,
                Animation.RELATIVE_TO_SELF, 0.0f);

        slide.setDuration(300);//from w w  w  .  j a  va 2s  .  c  o  m
        slide.setFillBefore(false);
        slide.setFillEnabled(false);
        panel.startAnimation(slide);

        slide.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                panel.clearAnimation();
                ViewGroup.LayoutParams lp = panel.getLayoutParams();
                lp.width = panel.getWidth();
                lp.height = panel.getHeight();
                panel.setLayoutParams(lp);
                panel.setVisibility(View.INVISIBLE);
            }
        });
    }

}

Related Tutorials