6

我有一个奇怪的问题 - 不时应该淡出我的控件(ImageButton)的动画不会立即启动。我正在使用淡出动画来隐藏它,然后在 myListener 的末尾(onAnimationEnd)我将新资源作为按钮上的图像。

在我的应用程序代码中的某处:

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(Animation a) 中:

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

似乎有一个规则,每4个或5个动画不开始......

感谢帮助!

4

2 回答 2

11

添加

buttons[location].invalidate(); 

a.startNow();

解决了我的问题。

于 2010-08-31T04:13:35.343 回答
3

你也可以使用

buttons[location].startAnimation(a);
于 2012-09-25T14:28:02.347 回答