Android Scene Transition Animation when starting multiple activities

送分小仙女□ 提交于 2019-12-13 20:12:12

问题


I'd like to use ActivityOptionsCompat.makeSceneTransitionAnimation to do a scene transition between 2 UI elements but I also need to start multiple activities. This code causes issues (prevents the second activity from even starting). I can start the activities individually to pass the options to the correct activity, but that has its own issues with a flickering UI. Is there another way to accomplish this?

if (targetActivity == TargetActivity.HOMEPAGE) {
        baseActivity.startActivity(homeIntent)
    } else {
        val targetIntent = argumentBuilder.toIntent(baseActivity, targetActivity.clazz)
        val intents = arrayOf(homeIntent, targetIntent)

        val options = ActivityOptionsCompat.makeSceneTransitionAnimation(baseActivity, view.targetUserImage, "transition_to_inbox")
        baseActivity.startActivities(intents, options.toBundle())
    }

回答1:


That isn't supported. The framework is designed to transition from one Activity to another within the same task. If you start multiple activities, it has no idea what you intend with respect to UI elements.



来源:https://stackoverflow.com/questions/44770089/android-scene-transition-animation-when-starting-multiple-activities

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!