-1

i have a imageButton with a animation(moving from point A to B), and i want to make him invisible if I click it, the problem is, the button doesn't become invisible while the animation is on.

Animation code:

Animation animation = new TranslateAnimation(0, 0,-500, 600); 
animation.setDuration(6000); 
animation.setFillAfter(true); 
rndCoin.startAnimation(animation); 
Ian Turton
  • 10,018
  • 1
  • 28
  • 47

1 Answers1

2

You problem is that you are using View animation, and it makes you button unclickable until your animation ends.

There are two types of animation:

View animation: It's a more simple and easier to use, but you have some limitation (like the one you have right now!) - You can check more about it here

Property Animation: It is a more robust framework. You don't necessarily have to use this with Views, you can animate pretty much anything... Just use your creativity. With this kind of animation you will be able to change the visibility of your button while the animation is going on. Take a look here for more info.

Source: Android Animation - Button stays clickable

Community
  • 1
  • 1
Leandro Borges Ferreira
  • 12,422
  • 10
  • 53
  • 73