Chapter 35 Material Design
Then we defined a static method startWithTransition(...) to set the same transition name on a view
to animate from.
Listing 35.8 Starting with transition method
public static void startWithTransition(Activity activity, Intent intent,
View sourceView) {
ViewCompat.setTransitionName(sourceView, "image");
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation(activity, sourceView, "image");
activity.startActivity(intent, options.toBundle());
}
ViewCompat.setTransitionName(View, String) is there to help out on older versions of Android,
where View will not have a setTransitionName(String) implementation.
In Listing 35.8, you can see the final step, too: making an ActivityOptions. The ActivityOptions
tells the OS what the shared elements are and what transitionName value to use.
There is a lot more to know about transitions and shared element transitions. They can also be used for
fragment transitions, for example. For more information, check out Google’s documentation for the
transitions framework at developer.android.com/training/transitions/overview.html.