Android – activityoptions.makescenetransitionanimation cannot use multiple views in kotlin

This is my kotlin code for active transition animation

    val p1 = Pair.create(imageViewhospitals, "hospitals")
    val p2 = Pair.create(textViewhospitals, "title")

    val options = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        ActivityOptions.makeSceneTransitionAnimation(this, p1, p2)
                    } else {
                        TODO("VERSION.SDK_INT < LOLLIPOP")
                    }
startActivity(Intent(this,SplashActivity::class.java),options.toBundle())

I received an error / warning

On activityoptions.makescenetransitionanimation

resolvent:

Finally, I solve this problem through change

val p1 = Pair.create(imageViewhospitals, "hospitals")
val p2 = Pair.create(textViewhospitals, "title")

to

val p1 = Pair.create<View, String>(imageViewhospitals, "hospitals")
val p2 = Pair.create<View, String>(textViewhospitals, "title")

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>