Android transitionName共享元素

效果


SVID_20201222_153820_1.gif


    
    

MaiActivity.kt

transitionImg.setOnClickListener {
            val pair = Pair(transitionImg, "transitionImg")
            val pair2 = Pair(transitionText, "transitionText")
            val bundle: Bundle = ActivityOptions.makeSceneTransitionAnimation(this, pair, pair2).toBundle()
            startActivity(Intent(this, TranslateActivity::class.java), bundle)
        }

activity_translate.xml




    

    

TranslateActivity.kt

class  TranslateActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_traslate)
    }
}

你可能感兴趣的:(Android transitionName共享元素)