Understanding exit/reenter shared element transitions

可紊 提交于 2019-11-30 02:05:00

As I recall, there is a bug in L that causes the shared element return transition to be interrupted if it takes longer than the reenter transition duration. If you adjust your reenter transition duration (on the calling Activity), that should fix the interruption problem until the bug is fixed in MR1.

The exit and reenter transitions are for executing stuff before the shared element is allowed to transition. For example, if you want to lift your shared element before transferring it, that would be done in the shared element exit transition. The reenter would be used to do the opposite -- drop the view after it was transferred back. Most apps don't need it, but it is there for the rare one that does.

  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.

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