Vincent.zZ

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

AnimationDrawable回到初始状态(重置)

用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上的答案

posted on 2014-11-29 11:18  Vincent.zZ  阅读(848)  评论(0)    收藏  举报