是否可以在 android 运行时更改 RotateAnimation 的值?
我正在使用 RotateAnimation,我想在动画运行时更改动画,例如,更改“toDegrees”参数,从而使动画更短或更长。
谢谢。
I'm using RotateAnimation and i want to change the animation while it's running, for example, changing the "toDegrees" parameter and thous making the animation shorter or longer.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可以帮助您(只需将 getter 和 setter 添加到所需字段)
This can help you (just added getters and setters to needed fields)
接受的答案对我不起作用。所需要的是当前动画的“平滑”延续而不会出现故障。相反,我稍微修改了 RotationAnimation 类以返回“当前使用”的度数,然后可以使用它:
这就是我使用它的方式:
这将每次创建一个新的动画,但是它会给人延续和动画的感觉将从“取消”的地方顺利继续。
The accepted answer didn't work for me. What's needed is 'smooth' continuation of the current animation without getting a glitch. Instead I modified the RotationAnimation class slightly to return the 'currently used' degrees, which can then be used:
And this is how I use it:
This would create a new animation each time, however it would give the feeling of continuation and the animation will smoothly continue from where it got 'cancelled'.
您有 cancel() startOffsetTime() 和 restrictDuration()。不过,我没有看到任何可以更改角度的 api,因此您可能必须启动一个新的
RotateAnitmation
You have cancel() startOffsetTime(), and restrictDuration(). I don't see any api to change the degree though, so you may have to start a new
RotateAnitmation