Android AnimationListener和AnimatorListener之间有什么区别?
我想使用此处指定的Android AnimationListener和AnimatorListener之间有什么区别?,android,animation,Android,Animation,我想使用此处指定的AnimatorListenerAdapter: 但是,它实现了AnimatorListener接口。在视图上,例如图像视图,有一个名为setAnimationListener()的方法,但它将AnimationListener作为参数。似乎没有相关的AnimationListenerAdapter可用 我的问题是AnimatorListener和AnimationListener之间有什么区别,为什么这两个独立的接口存在?看起来它们都提供相同的功能。我能看到的唯一区别是,其
AnimatorListenerAdapter
:
但是,它实现了AnimatorListener
接口。在视图
上,例如图像视图
,有一个名为setAnimationListener()
的方法,但它将AnimationListener
作为参数。似乎没有相关的AnimationListenerAdapter
可用
我的问题是
AnimatorListener
和AnimationListener
之间有什么区别,为什么这两个独立的接口存在?看起来它们都提供相同的功能。我能看到的唯一区别是,其中一个是在较新的API版本中引入的。AnimationListener
用于旧式的视图
动画,而AnimatorListener
用于新的(从3.0开始)Animator
API
所有的
AnimatorListenerAdapter
都是实现没有任何功能的AnimatorListener
接口。您可以通过创建一个公共的非最终类来轻松创建自己的AnimationListenerAdapter
,该类实现了AnimationListener
,但没有任何功能。对于我们这些懒惰的人:
import android.view.animation.Animation
/**
* Adapter to reduce code implementation of Animation.AnimationListener when there are unused
* functions.
*/
open class AnimationListenerAdapter: Animation.AnimationListener {
/**
*
* Notifies the start of the animation.
*
* @param animation The started animation.
*/
override fun onAnimationStart(animation: Animation) {
}
/**
*
* Notifies the end of the animation. This callback is not invoked
* for animations with repeat count set to INFINITE.
*
* @param animation The animation which reached its end.
*/
override fun onAnimationEnd(animation: Animation) {
}
/**
*
* Notifies the repetition of the animation.
*
* @param animation The animation which was repeated.
*/
override fun onAnimationRepeat(animation: Animation) {
}
}当然,您完全正确,我可以轻松创建自己的适配器,我只是希望我甚至不必这样做。(说到编程,我很懒。):>