makeSceneTransitionAnimation 在使用 AndroidX 时显示错误

makeSceneTransitionAnimation shows an error when using AndroidX

我有以下方法,当我使用 android.support.v4

时可以正常工作
override fun onClick(movie: Movie, poster: ImageView, name: TextView) {
            val intent = Intent(activity, DetailActivity::class.java).apply {
                putExtras(Bundle().apply {
                    putParcelable(EXTRA_MOVIE, movie)
                })
            }
            val activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
                    requireActivity(),

                    // Now we provide a list of Pair items which contain the view we can transitioning
                    // from, and the name of the view it is transitioning to, in the launched activity
                    Pair<View, String?>(poster, ViewCompat.getTransitionName(poster)),
                    Pair<View, String?>(name, ViewCompat.getTransitionName(name)))

            // Now we can start the Activity, providing the activity options as a bundle
            ActivityCompat.startActivity(requireContext(), intent, activityOptions.toBundle())
        }

现在我想迁移到 androidx.core.app。由于某种原因,它在 makeSceneTransitionAnimation 上显示错误,表示 non of the following functions can be called with the arguments supplied.

有人遇到过这样的问题吗?

对我来说,它是这样工作的:

//Watchout about this import, it is important!!
import androidx.core.util.Pair

//onCreate code avoided here
val testView = ImageView(this)

val activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
     MainActivity.this,
     Pair<View, String>(testView, "hi1"),
     Pair<View, String>(testView, "hi2")
)
// ... startActivity code here

使用这 2 个依赖项:

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.1'