Android APIs
public class

TransitionManager

extends Object
java.lang.Object
   ↳ android.transition.TransitionManager

Class Overview

This class manages the set of transitions that fire when there is a change of Scene. To use the manager, add scenes along with transition objects with calls to setTransition(Scene, Transition) or setTransition(Scene, Scene, Transition). Setting specific transitions for scene changes is not required; by default, a Scene change will use AutoTransition to do something reasonable for most situations. 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 transitionManagertag 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. This is equivalent to creating a scene from a layout in code by calling getSceneForLayout(ViewGroup, int, Context). For the transition attribute, there is a reference to a resource file in the res/transition directory which describes that transition.

Information on XML resource descriptions for transitions can be found for Transition, TransitionSet, TransitionTarget, Fade, and TransitionManager.

Summary

Public Constructors
TransitionManager()
Public Methods
static void beginDelayedTransition(ViewGroup sceneRoot, Transition transition)
Convenience method to animate to a new scene defined by all changes within the given scene root between calling this method and the next rendering frame.
static void beginDelayedTransition(ViewGroup sceneRoot)
Convenience method to animate, using the default transition, to a new scene defined by all changes within the given scene root between calling this method and the next rendering frame.
static void go(Scene scene)
Convenience method to simply change to the given scene using the default transition for TransitionManager.
static void go(Scene scene, Transition transition)
Convenience method to simply change to the given scene using the given transition.
void setTransition(Scene fromScene, Scene toScene, Transition transition)
Sets a specific transition to occur when the given pair of scenes is exited/entered.
void setTransition(Scene scene, Transition transition)
Sets a specific transition to occur when the given scene is entered.
void transitionTo(Scene scene)
Change to the given scene, using the appropriate transition for this particular scene change (as specified to the TransitionManager, or the default if no such transition exists).
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public TransitionManager ()

Added in API level 19

Public Methods

public static void beginDelayedTransition (ViewGroup sceneRoot, Transition transition)

Added in API level 19

Convenience method to animate to a new scene defined by all changes within the given scene root between calling this method and the next rendering frame. Calling this method causes TransitionManager to capture current values in the scene root and then post a request to run a transition on the next frame. At that time, the new values in the scene root will be captured and changes will be animated. There is no need to create a Scene; it is implied by changes which take place between calling this method and the next frame when the transition begins.

Calling this method several times before the next frame (for example, if unrelated code also wants to make dynamic changes and run a transition on the same scene root), only the first call will trigger capturing values and exiting the current scene. Subsequent calls to the method with the same scene root during the same frame will be ignored.

Passing in null for the transition parameter will cause the TransitionManager to use its default transition.

Parameters
sceneRoot The root of the View hierarchy to run the transition on.
transition The transition to use for this change. A value of null causes the TransitionManager to use the default transition.

public static void beginDelayedTransition (ViewGroup sceneRoot)

Added in API level 19

Convenience method to animate, using the default transition, to a new scene defined by all changes within the given scene root between calling this method and the next rendering frame. Equivalent to calling beginDelayedTransition(ViewGroup, Transition) with a value of null for the transition parameter.

Parameters
sceneRoot The root of the View hierarchy to run the transition on.

public static void go (Scene scene)

Added in API level 19

Convenience method to simply change to the given scene using the default transition for TransitionManager.

Parameters
scene The Scene to change to

public static void go (Scene scene, Transition transition)

Added in API level 19

Convenience method to simply change to the given scene using the given transition.

Passing in null for the transition parameter will result in the scene changing without any transition running, and is equivalent to calling exit() on the scene root's current scene, followed by enter() on the scene specified by the scene parameter.

Parameters
scene The Scene to change to
transition The transition to use for this scene change. A value of null causes the scene change to happen with no transition.

public void setTransition (Scene fromScene, Scene toScene, Transition transition)

Added in API level 19

Sets a specific transition to occur when the given pair of scenes is exited/entered.

Parameters
fromScene The scene being exited when the given transition will be run
toScene The scene being entered when the given transition will be run
transition The transition that will play when the given scene is entered. A value of null will result in the default behavior of using the default transition instead.

public void setTransition (Scene scene, Transition transition)

Added in API level 19

Sets a specific transition to occur when the given scene is entered.

Parameters
scene The scene which, when applied, will cause the given transition to run.
transition The transition that will play when the given scene is entered. A value of null will result in the default behavior of using the default transition instead.

public void transitionTo (Scene scene)

Added in API level 19

Change to the given scene, using the appropriate transition for this particular scene change (as specified to the TransitionManager, or the default if no such transition exists).

Parameters
scene The Scene to change to