animation.start()或animation.startNow()不会立即启动动画动画、animation、start、startNow

由网友(我爱你 ̄终究还是爱错了你)分享简介:我有一个奇怪的问题 - 不时应该淡出我的控制(的ImageButton)不会立即一命呜呼动画。我使用的是淡出动画来隐藏它,然后在myListener的在其末端(onAnimationEnd)我提出了新的资源作为按钮上的图像。 I have a strange issue - from time to time the...

我有一个奇怪的问题 - 不时应该淡出我的控制(的ImageButton)不会立即一命呜呼动画。我使用的是淡出动画来隐藏它,然后在myListener的在其末端(onAnimationEnd)我提出了新的资源作为按钮上的图像。

I have a strange issue - from time to time the animation that should fade out my control (ImageButton) does not kick in immediately. I am using the fadeout animation to hide it and then in myListener on its end (onAnimationEnd) I put new resource as the image on the button.

在某处我的应用程序code:

Somewhere in my app code:

Animation a = AnimationUtils.loadAnimation(this,R.anim.fadeout); 
a.setAnimationListener(new myListener(location));
buttons[location].setAnimation(a);
a.startNow(); // regardless if its start() or startnNow() 
              // it will work in most of the cases but not 100% reliable
              // I actually can see in debug Log when its late, happens after few more clicks

然后在myListener.onAnimationEnd(动画):

Then in myListener.onAnimationEnd(Animation a):

buttons[location].setImageResource(R.drawable.standard_button);

似乎还有一个规则,即每4个或第五动画没有开始... ...

Seems there is a rule that the every 4th or 5th animation does not start ...

感谢您的帮助!

推荐答案

添加

buttons[location].invalidate(); 

a.startNow();

有固定我的问题。

has fixed my issue.

阅读全文

相关推荐

最新文章