您的位置:首页 > 其它

AnimationDrawable回到初始状态(重置)

2017-08-21 14:21 351 查看
用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);


回到第一帧
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  动画