如何获取开始动画的View对象......?
我有 3 个图像视图,其中我开始了相同的动画(翻译)
我有动画侦听器,在 onAnimationEnd(动画动画) 方法中,
我想知道动画在哪个图像视图上结束..?
从动画对象我如何知道它是在哪个位置开始的..?
提前致谢..!
I have 3 image view in which i started same animation (translate)
I have animation listener, in onAnimationEnd(Animation animation) method,
I want to know on which image view the animation is ended..?
From animation object how can I know in which it was started..?
Thanks in advance..!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么你无法知道动画结束的对象是什么。 AnimationListener 的全部目的是监听动画而不是对象。
解决方案
1- 创建您自己的动画类并在其中保存对正在制作动画的对象的引用。
这将允许您在函数
onAnimationEnd
中将动画转换为 YourAnimation 并获取引用。2- 一个更简单的解决方案是创建您自己的AnimationListener,它保存动画对象的引用。
例如:
因此,当您想要为 ImageView 制作动画时:您可以执行以下操作:
Well you can not know what is the object on which the animation ended. The whole purpose of the AnimationListener is to listen to the Animation and not to the object.
Solution
1- Create your own Animation class and save in it a reference to the object which is animating.
This will allow you to cast the Animation to YourAnimation in the function
onAnimationEnd
and get the reference.2- A simpler solution is to create your own AnimationListener that holds a reference of the Object that is animated.
For example:
So when you want to animate your ImageView: You do the following: