当我想在Kotlin 制作TextView
中的textColor
的动画时:
val animator = ObjectAnimator.ofInt(myTextView, "textColor", 0xFF8363FF, 0xFFC953BE)
this error occurs:
Error:(124, 43) None of the following functions can be called with the arguments supplied:
public open fun <T : Any!> ofInt(target: TextView!, xProperty: Property<TextView!, Int!>!, yProperty: Property<TextView!, Int!>!, path: Path!): ObjectAnimator! defined in android.animation.ObjectAnimator
public open fun <T : Any!> ofInt(target: TextView!, property: Property<TextView!, Int!>!, vararg values: Int): ObjectAnimator! defined in android.animation.ObjectAnimator
public open fun ofInt(target: Any!, propertyName: String!, vararg values: Int): ObjectAnimator! defined in android.animation.ObjectAnimator
public open fun ofInt(target: Any!, xPropertyName: String!, yPropertyName: String!, path: Path!): ObjectAnimator! defined in android.animation.ObjectAnimator
public open fun ofInt(vararg values: Int): ValueAnimator! defined in android.animation.ObjectAnimator
Seems that the value 0xFF8363FF
and 0xFFC953BE
cannot be cast to Int
in Kotlin, however, it's normal in Java:
ObjectAnimator animator = ObjectAnimator.ofInt(myTextView, "textColor", 0xFF8363FF, 0xFFC953BE);
Any ideas? Thanks in advance.