//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
使用这两个依赖项:
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.1'