# TransitionManager

Artifact: [androidx.transition:transition](https://developer.android.com/jetpack/androidx/releases/transition) [View Source](https://cs.android.com/search?q=file:androidx/transition/TransitionManager.java+class:androidx.transition.TransitionManager) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/transition#1.0.0)

*** ** * ** ***


```
public class TransitionManager
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/transition/TransitionManager#TransitionManager()()` |

| ### Public methods |
|---|---|
| `static void` | `https://developer.android.com/reference/androidx/transition/TransitionManager#beginDelayedTransition(android.view.ViewGroup)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html 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` | `https://developer.android.com/reference/androidx/transition/TransitionManager#beginDelayedTransition(android.view.ViewGroup,androidx.transition.Transition)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html sceneRoot, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/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 @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/TransitionSeekController` | `https://developer.android.com/reference/androidx/transition/TransitionManager#controlDelayedTransition(android.view.ViewGroup,androidx.transition.Transition)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html sceneRoot, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Transition transition )` Create a `https://developer.android.com/reference/androidx/transition/TransitionSeekController` to allow seeking an animation to a new scene defined by all changes within the given scene root between calling this method and the next rendered frame. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/TransitionSeekController` | `https://developer.android.com/reference/androidx/transition/TransitionManager#createSeekController(androidx.transition.Scene,androidx.transition.Transition)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene scene, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Transition transition)` Convenience method to seek to the given scene using the given transition. |
| `static void` | `https://developer.android.com/reference/androidx/transition/TransitionManager#endTransitions(android.view.ViewGroup)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/ViewGroup.html sceneRoot)` Ends all pending and ongoing transitions on the specified scene root. |
| `static void` | `https://developer.android.com/reference/androidx/transition/TransitionManager#go(androidx.transition.Scene)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene scene)` Convenience method to simply change to the given scene using the default transition for TransitionManager. |
| `static void` | `https://developer.android.com/reference/androidx/transition/TransitionManager#go(androidx.transition.Scene,androidx.transition.Transition)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene scene, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/Transition transition)` Convenience method to simply change to the given scene using the given transition. |
| `void` | `https://developer.android.com/reference/androidx/transition/TransitionManager#setTransition(androidx.transition.Scene,androidx.transition.Transition)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene scene, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/Transition transition)` Sets a specific transition to occur when the given scene is entered. |
| `void` | `https://developer.android.com/reference/androidx/transition/TransitionManager#setTransition(androidx.transition.Scene,androidx.transition.Scene,androidx.transition.Transition)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene fromScene, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene toScene, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/Transition transition )` Sets a specific transition to occur when the given pair of scenes is exited/entered. |
| `void` | `https://developer.android.com/reference/androidx/transition/TransitionManager#transitionTo(androidx.transition.Scene)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/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). |

## Public constructors

### TransitionManager

Added in 1.0.0

```
public TransitionManager()
```

## Public methods

### beginDelayedTransition

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/transition#1.0.0)

```
public static void beginDelayedTransition(@NonNull 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. Equivalent to calling `https://developer.android.com/reference/androidx/transition/TransitionManager#beginDelayedTransition(android.view.ViewGroup,androidx.transition.Transition)` with a value of `null` for the `transition` parameter.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html sceneRoot` | The root of the View hierarchy to run the transition on. |

### beginDelayedTransition

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/transition#1.0.0)

```
public static void beginDelayedTransition(
    @NonNull ViewGroup sceneRoot,
    @Nullable 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. 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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html sceneRoot` | The root of the View hierarchy to run the transition on. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/Transition transition` | The transition to use for this change. A value of null causes the TransitionManager to use the default transition. |

### controlDelayedTransition

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/transition#1.5.0)

```
public static @Nullable TransitionSeekController controlDelayedTransition(
    @NonNull ViewGroup sceneRoot,
    @NonNull Transition transition
)
```

Create a `https://developer.android.com/reference/androidx/transition/TransitionSeekController` to allow seeking an animation to a new scene defined by all changes within the given scene root between calling this method and the next rendered 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.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html sceneRoot` | The root of the View hierarchy to run the transition on. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Transition transition` | The transition to use for this change. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/TransitionSeekController` | a `https://developer.android.com/reference/androidx/transition/TransitionSeekController` that can be used control the animation to the destination scene. `null` is returned when seeking is not supported on the scene, either because it is running on `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#TIRAMISU` or earlier, another Transition is being captured for `sceneRoot`, or `sceneRoot` hasn't had a layout yet. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `transition` returns `false` from `https://developer.android.com/reference/androidx/transition/Transition#isSeekingSupported()`. |

### createSeekController

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/transition#1.5.0)

```
public static @Nullable TransitionSeekController createSeekController(@NonNull Scene scene, @NonNull Transition transition)
```

Convenience method to seek to the given scene using the given transition. If seeking is not supported because the device is Build.VERSION_CODES.TIRAMISU or earlier, the scene transition is immediate and `null` is returned.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene scene` | The Scene to change to |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Transition transition` | The transition to use for this scene change. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/TransitionSeekController` | a `https://developer.android.com/reference/androidx/transition/TransitionSeekController` that can be used control the animation to the destination scene. `null` is returned when seeking is not supported on the scene, either because it is running on android.os.Build.VERSION_CODES.TIRAMISU or earlier, another Transition is being captured for `sceneRoot`, or `sceneRoot` hasn't had a layout yet. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `transition` returns `false` from `https://developer.android.com/reference/androidx/transition/Transition#isSeekingSupported()`. |

### endTransitions

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/transition#1.0.0)

```
public static void endTransitions(@Nullable ViewGroup sceneRoot)
```

Ends all pending and ongoing transitions on the specified scene root.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/ViewGroup.html sceneRoot` | The root of the View hierarchy to end transitions on. |

### go

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/transition#1.0.0)

```
public static void go(@NonNull Scene scene)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene scene` | The Scene to change to |

### go

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/transition#1.0.0)

```
public static void go(@NonNull Scene scene, @Nullable Transition transition)
```

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 `https://developer.android.com/reference/androidx/transition/Scene#exit()` on the scene root's current scene, followed by `https://developer.android.com/reference/androidx/transition/Scene#enter()` on the scene specified by the `scene` parameter.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene scene` | The Scene to change to |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/Transition transition` | The transition to use for this scene change. A value of null causes the scene change to happen with no transition. |

### setTransition

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/transition#1.0.0)

```
public void setTransition(@NonNull Scene scene, @Nullable Transition transition)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene scene` | The scene which, when applied, will cause the given transition to run. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/Transition 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. |

### setTransition

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/transition#1.0.0)

```
public void setTransition(
    @NonNull Scene fromScene,
    @NonNull Scene toScene,
    @Nullable Transition transition
)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene fromScene` | The scene being exited when the given transition will be run |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene toScene` | The scene being entered when the given transition will be run |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/transition/Transition 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. |

### transitionTo

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/transition#1.0.0)

```
public void transitionTo(@NonNull 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).

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/transition/Scene scene` | The Scene to change to |