小编A.N*_*N.T的帖子

ObjectAnimator.ofFloat不能直接在Kotlin中将Int作为参数

我正在研究kotlin项目,我尝试将java中的方法转换为kotlin.我现在收到此错误

使用提供的参数不能调用以下任何函数.

它发生在 ObjectAnimator.ofFloat()

守则如下

fun animate(holder: RecyclerView.ViewHolder, goesDown: Boolean) {

    val animat = AnimatorSet()

    val objectY = ObjectAnimator.ofFloat(holder.itemView, "translationY", if (goesDown) 200 else -200, 0)
    objectY.setDuration(Kons.Duration.toLong())

    val objectX = ObjectAnimator.ofFloat(holder.itemView, "translationX", -50, 50, -30, 30, -20, 20, -5, 5, 0)
    objectX.setDuration(Kons.Duration.toLong())

    animat.playTogether(objectX, objectY)
    animat.start()
}
Run Code Online (Sandbox Code Playgroud)

android kotlin

11
推荐指数
1
解决办法
3515
查看次数

标签 统计

android ×1

kotlin ×1