[英]How do I add Listener to ObjectAnimator in Kotlin?
我做了这样的事情
val animator = ObjectAnimator.ofFloat(view, "translationY", 350f,0f)
animator.duration = 500
animator.startDelay=200
animator.interpolator =AccelerateDecelerateInterpolator()
animator.start()
现在我正在尝试将侦听器添加到此适配器。 我试过这个,
animator.addListener(onStart = {view.visibility=View.VISIBLE})
但不工作。
尽管您的问题不清楚,因为您没有提到什么不起作用。 我的猜测是你的听众没用。
您正在启动动画制作器,然后添加它,这当然永远不会被调用。
更改如下:
val animator = ObjectAnimator.ofFloat(view, "translationY", 350f, 0f)
animator.apply {
duration = 500
startDelay = 200
addListener(onStart = {
view.visibility = View.VISIBLE
})
AccelerateDecelerateInterpolator()
start()
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.