我有一个奇怪的问题--有时应该淡出我控制的动画(ImageButton)不会立即生效。我使用淡出动画来隐藏它,然后在它的末端(onAnimationEnd)的myListener中,我将新的资源作为图像放在按钮上。
在我的应用代码中的某处:
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个动画不开始...
感谢您的帮助!
发布于 2010-08-31 12:13:35
添加
buttons[location].invalidate();
之后
a.startNow();
解决了我的问题。
发布于 2012-09-25 22:28:02
您还可以使用
buttons[location].startAnimation(a);
https://stackoverflow.com/questions/3604048
复制相似问题