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(newAnimation.AnimationListener() {

@Override
public voidonAnimationStart(Animation animation) {}

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

@Override
public voidonAnimationRepeat(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(newOnClickListener() {

    @OverridepublicvoidonClick(View v) {
//gone myselft (againbtn)
        againbtn.setVisibility(View.GONE);
        //answer button on animationAnimationanim2= 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);
AnimationListeneranimButnListener=newAnimationListener(){
  @OverridepublicvoidonAnimationEnd(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"