Search code examples
androidanimationviewkotlintransition

ActivityOptions.makeSceneTransitionAnimation not working in kotlin with multiple views


This is my Kotlin code for activity 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 am getting an error/warning like

none of the following function can be called with the arguments supplied

on ActivityOptions.makeSceneTransitionAnimation


Solution

  • Finally I have solved this problem by changing from

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