How to hide the view when animating in android?

I have a simple one LinearLayoutwith two buttons next to it. They should enter and exit the field of view on the right side of the screen when necessary. I am working on animation and the rest of the work is completed, but I have one last problem to solve.

How to adjust visibility LinearLayoutto View.GONEafter completion of a slide animation? I need it to disappear after the screen.

+5
source share
3 answers

Take the link of your Animationanimation object . Call Animation#setAnimationListenerand in the listener method onAnimationEndset the visibility to View.GONE.

+11
source

: fooobar.com/questions/80375/...

anim.setAnimationListener(new Animation.AnimationListener(){
  @Override
  public void onAnimationStart(Animation arg0) {
  }           
  @Override
  public void onAnimationRepeat(Animation arg0) {
  }           
  @Override
  public void onAnimationEnd(Animation arg0) {
  }
});
+2
LinearLayout al = (LinearLayout) findViewById(R.id.layoutid);  
al.setVisibility(view.INVISIBLE);

onAnimationEnd(){
}
0
source

All Articles