animation.start()或animation.startNow()不会立即启动动画
-
25-09-2019 - |
题
我有一个奇怪的问题 - 不时应淡出我的控制动画(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(动画A):
buttons[location].setImageResource(R.drawable.standard_button);
似乎有一个规则,即每4个或5动画无法启动......
感谢您的帮助!
解决方案
添加
buttons[location].invalidate();
后
a.startNow();
有固定我的问题。
其他提示
您还可以使用
buttons[location].startAnimation(a);
不隶属于 StackOverflow