hide Slide From Bottom - Android android.view.animation

Android examples for android.view.animation:slide Animation

Description

hide Slide From Bottom

Demo Code

import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;

public class Main {

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

    slide.setDuration(300);/*from   w  ww. ja  v a2s  .  c  o  m*/
    slide.setFillAfter(true);
    slide.setFillEnabled(true);
    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