Skip to content Skip to sidebar Skip to footer

Invisibility And GONE Doesnt Work After Animation In Android

i use this code to when i click on a imagebox, run an animation on another object and dissaper itself via visibility.GONE. but it doesnt work!! here is my code: againbtn.setOnClic

Solution 1:

Try this You have to clear the view animation then you can setVisibility

animation.setAnimationListener(new Animation.AnimationListener() {

@Override
public void onAnimationStart(Animation animation) {}

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

@Override
public void onAnimationRepeat(Animation animation) {}
            });

Solution 2:

You should implement Animation Listener and in onAnimationEnd() you should perform your task... hope below code will help you...

anim2.setAnimationListener(new Animation.AnimationListener(){
    @Override
    public void onAnimationStart(Animation arg0) {
    }           

    @Override
    public void onAnimationRepeat(Animation arg0) {
    }           

    @Override
    public void onAnimationEnd(Animation arg0) {
        againbtn.setVisibility(View.GONE);  //set your button visibility here
    }


});

Solution 3:

I think put visibility button before animation coding the this might work

 againbtn.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
//gone myselft (againbtn)
        againbtn.setVisibility(View.GONE);
        //answer button on animation
   Animation anim2 = AnimationUtils.loadAnimation(MainActivity.this,           R.anim.askbtnonanim);
         anim2.setFillAfter(true);
        askbtn.startAnimation(anim2);


    }
});

Solution 4:

Calling clearAnimation() on the view that is doing the animation before calling View.INVISIBLE, or GONE does the trick.


Solution 5:

use AnimationListener for setting Button Visibility GONE when Animation end.

.....
anim2.setAnimationListener(animButnListener);
askbtn.startAnimation(anim2);
AnimationListener animButnListener = new AnimationListener(){
  @Override
  public void onAnimationEnd(Animation animation) {

   // make  Button Visibility GONE  here
    againbtn.setVisibility(View.GONE);
  }
  //.......other AnimationListener methods
};

Post a Comment for "Invisibility And GONE Doesnt Work After Animation In Android"