FEATURE_ACTIVITY_TRANSITIONS vs. FEATURE_CONTENT_TRANSITIONS FEATURE_ACTIVITY_TRANSITIONS vs. FEATURE_CONTENT_TRANSITIONS android android

FEATURE_ACTIVITY_TRANSITIONS vs. FEATURE_CONTENT_TRANSITIONS


I'm glad I have an opportunity to answer these questions as the documentation is less than clear.

Early-on, there was one flag FEATURE_CONTENT_TRANSITIONS that handled both of the features. We split them when Material applications got unexpected behavior when it was enabled. So some older documentation may still say that you have to enable FEATURE_CONTENT_TRANSITIONS to get activity transitions when they mean FEATURE_ACTIVITY_TRANSITIONS.

  1. What is the difference between these two flags? What is the difference between an "activity transition" and a "content transition" in this context?

An activity transition in this context means that you call startActivity with a bundle created from ActivityOptions.makeSceneTransitionAnimation or, your activity was started with that bundle. Activity Transitions modify your layout (e.g. fading in elements, moving shared elements), so if your activity doesn't like that, you should disable FEATURE_ACTIVITY_TRANSITIONS.

Content transitions use a TransitionManager when you call setContentView (other than the first time). Typically, you'll get a cross-fade, but if your Activity's content has things in common, such as sharing IDs or using transitionName, you'll get ChangeBounds behavior between those Views. You can change the details of your transitions by customizing the TransitionManager associated with your Window either using XML or code.

  1. Why is FEATURE_ACTIVITY_TRANSITIONS enabled and FEATURE_CONTENT_TRANSITIONS disabled by default? When is enabling the FEATURE_CONTENT_TRANSITIONS flag actually required?

FEATURE_CONTENT_TRANSITIONS uses a TransitionManager when your content changes. By default, this is a cross-fade and that was very bad for some applications. On the other hand, FEATURE_ACTIVITY_TRANSITIONS doesn't do anything to most applications by default. You have to opt into starting an activity that way, so it is safe to turn on.

  1. Would it ever make sense to sense to disable FEATURE_ACTIVITY_TRANSITIONS and enable FEATURE_CONTENT_TRANSITIONS? Or does FEATURE_CONTENT_TRANSITIONS require FEATURE_ACTIVITY_TRANSITIONS to be enabled as well?

Yes, but it is unlikely. If your application likes FEATURE_CONTENT_TRANSITIONS, it should work well with FEATURE_ACTIVITY_TRANSITIONS. If you want to explicitly limit people from calling your activity with shared elements or you don't like the standard enter transition effect, you can disable it to prevent the effect when another applications calls into yours.