首页 > 其他 > 详细

AnimationDrawable回到初始状态(重置)

时间:2014-11-29 11:40:48      阅读:935      评论:0      收藏:0      [点我收藏+]

用AnimationDrawable的时候发现只有start()和stop(),但是需要把动画重新返回初始状态的时候怎么办?

 

解决方法1:

((AnimationDrawable)(someButton.getBackground())).stop();
someButton.setBackgroundDrawable(null);
someButton.setBackgroundResource(R.drawable.animation);

 

someButton.setBackgroundDrawable(null);这句会kill掉view的背景的动画

解决方法2:

timerAnimation.stop();
timerAnimation.selectDrawable(0);

回到第一帧

 

这是在stackoverflow上的答案

AnimationDrawable回到初始状态(重置)

原文:http://www.cnblogs.com/Vincent0013/p/4130422.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!