如何在Kotlin中将侦听器添加到ObjectAnimator?

问题描述 投票:0回答:1

我做了这样的事情

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})

但不起作用。

android kotlin objectanimator
1个回答
0
投票
val animator = ObjectAnimator.ofFloat(view, "translationY", 350f, 0f) animator.apply { duration = 500 startDelay = 200 animator.addListener(onStart = { view.visibility = View.VISIBLE }) AccelerateDecelerateInterpolator() start() }
© www.soinside.com 2019 - 2024. All rights reserved.