Understanding exit/reenter shared element transitions

后端 未结 2 778
时光说笑
时光说笑 2020-12-25 15:29

I\'m doing some rudimentary exploration of Shared Element Transitions in Android L. The simple example I\'ve setup has an image view translating from the top of the screen t

2条回答
  •  猫巷女王i
    2020-12-25 16:07

    1. You shouldn't call finishAfterTransition() in onBackPressed(). The Activity super class will already do this for you.

    2. You should call requestFeature() before super.onCreate(). Requesting Window.FEATURE_ACTIVITY_TRANSITIONS is not necessary if you are using the Theme.Material theme (or similar).

    3. Calling setAllowEnterTransitionOverlap(false) and setAllowReturnTransitionOverlap(false) is redundant here. These determine the activity's window content transitions overlap... they don't affect the activity's shared element content transitions at all.

    4. Setting exit and reenter shared element transitions is rarely necessary. You almost always want to use enter and return transitions instead. If you set only the exit and reenter shared element transitions and leave the enter and return shared element transitions null, the called activity will have no way of knowing how to animate the shared elements when the transition begins, and the animation will appear to be broken.

提交回复
热议问题