我做了这样的事情
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()
}
关于android - 如何在 Kotlin 中为 ObjectAnimator 添加监听器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58214142/