HomeAndroidUnderstanding Android TransitionManager

Understanding Android TransitionManager

TransitionManager class which was added in Android API level 19,Ā manages the set of transitions that fire when there is a change of SCENE.Ā 

To use the TransitionManager, you have to add the scenes along with the associated transition objects with calls toĀ setTransition(Scene, Transition)orĀ setTransition(Scene, Scene, Transition).

It is not a mandate to set specific transitions for scene changes; a Scene change in this scenario will use AutoTransition. AutoTransition is aĀ utility class for creating a default transition that automatically fades, moves, and resizes views during a scene change.

An AutoTransition can be described in a resource file by using the tagĀ autoTransition, along with the other standard attributes ofĀ Transition.

Specifying other transitions for particular scene changes is only necessary if the application wants different transition behavior in these situations.

TransitionManagers can be declared in XML resource files inside theĀ res/transitionĀ directory. TransitionManager resources consist of theĀ transitionManager tag name, containing one or moreĀ transitionĀ tags, each of which describe the relationship of that transition to the from/to scene information in that tag. For example, here is a resource file that declares several scene transitions:

<transitionManager xmlns:android="http://schemas.android.com/apk/res/android">
Ā  Ā  <transition android:fromScene="@layout/transition_scene1"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  android:toScene="@layout/transition_scene2"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  android:transition="@transition/changebounds"/>
Ā  Ā  <transition android:fromScene="@layout/transition_scene2"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  android:toScene="@layout/transition_scene1"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  android:transition="@transition/changebounds"/>
Ā  Ā  <transition android:toScene="@layout/transition_scene3"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  android:transition="@transition/changebounds_fadein_together"/>
Ā  Ā  <transition android:fromScene="@layout/transition_scene3"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  android:toScene="@layout/transition_scene1"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  android:transition="@transition/changebounds_fadeout_sequential"/>
Ā  Ā  <transition android:fromScene="@layout/transition_scene3"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  android:toScene="@layout/transition_scene2"
Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  android:transition="@transition/changebounds_fadeout_sequential"/>
</transitionManager>

For each of the fromScene and toScene attributes, there is a reference to a standard XML layout file.

For the transition attribute, there is a reference to a resource file in the res/transition directory which describes that transition.

RELATED ARTICLES

Most Popular