# Scene

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:transition:28.0.0-alpha1  
Summary:[Ctors](https://developer.android.com/reference/android/support/transition/Scene#pubctors)\|[Methods](https://developer.android.com/reference/android/support/transition/Scene#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/transition/Scene#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/transition/Scene#)  

# Scene

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
Scene
`  
`

extends Object


``


`

|---|----------------------------------|
| java.lang.Object                    ||
| ↳ | android.support.transition.Scene |

<br />

*** ** * ** ***

A scene represents the collection of values that various properties in the View hierarchy will have when the scene is applied. A Scene can be configured to automatically run a Transition when it is applied, which will animate the various property changes that take place during the scene change.

## Summary

|                                                                                                                                                                                                                               ### Public constructors                                                                                                                                                                                                                                ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Scene](https://developer.android.com/reference/android/support/transition/Scene#Scene(android.view.ViewGroup))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` sceneRoot) ` Constructs a Scene with no information about how values will change when this scene is applied.                                                                                                                                                               |
| ` `[Scene](https://developer.android.com/reference/android/support/transition/Scene#Scene(android.view.ViewGroup, android.view.View))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` sceneRoot, `[View](https://developer.android.com/reference/android/view/View.html)` layout) ` Constructs a Scene which, when entered, will remove any children from the sceneRoot container and add the layout object as a new child of that container. |

|                                                                                                                                                                                                                                                                              ### Public methods                                                                                                                                                                                                                                                                              ||
|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                     | ` `[enter](https://developer.android.com/reference/android/support/transition/Scene#enter())`() ` Enters this scene, which entails changing all values that are specified by this scene.                                                                                                                                                                                                                                                                                        |
| ` void`                                                                                     | ` `[exit](https://developer.android.com/reference/android/support/transition/Scene#exit())`() ` Exits this scene, if it is the current scene on the scene's[scene root](https://developer.android.com/reference/android/support/transition/Scene#getSceneRoot()).                                                                                                                                                                                                               |
| ` static `[Scene](https://developer.android.com/reference/android/support/transition/Scene) | ` `[getSceneForLayout](https://developer.android.com/reference/android/support/transition/Scene#getSceneForLayout(android.view.ViewGroup, int, android.content.Context))`(`[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)` sceneRoot, int layoutId, `[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Returns a Scene described by the resource file associated with the given`layoutId`parameter. |
| ` `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)         | ` `[getSceneRoot](https://developer.android.com/reference/android/support/transition/Scene#getSceneRoot())`() ` Gets the root of the scene, which is the root of the view hierarchy affected by changes due to this scene, and which will be animated when this scene is entered.                                                                                                                                                                                               |
| ` void`                                                                                     | ` `[setEnterAction](https://developer.android.com/reference/android/support/transition/Scene#setEnterAction(java.lang.Runnable))`(Runnable action) ` Scenes that are not defined with layout resources or hierarchies, or which need to perform additional steps after those hierarchies are changed to, should set an enter action, and possibly an exit action as well.                                                                                                       |
| ` void`                                                                                     | ` `[setExitAction](https://developer.android.com/reference/android/support/transition/Scene#setExitAction(java.lang.Runnable))`(Runnable action) ` Scenes that are not defined with layout resources or hierarchies, or which need to perform additional steps after those hierarchies are changed to, should set an enter action, and possibly an exit action as well.                                                                                                         |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/transition/Scene#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public constructors

### Scene

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Scene (ViewGroup sceneRoot)
```

Constructs a Scene with no information about how values will change when this scene is applied. This constructor might be used when a Scene is created with the intention of being dynamically configured, through setting[setEnterAction(Runnable)](https://developer.android.com/reference/android/support/transition/Scene#setEnterAction(java.lang.Runnable))and possibly[setExitAction(Runnable)](https://developer.android.com/reference/android/support/transition/Scene#setExitAction(java.lang.Runnable)).

<br />

|                                                     Parameters                                                     ||
|-------------|-------------------------------------------------------------------------------------------------------|
| `sceneRoot` | `ViewGroup`: The root of the hierarchy in which scene changes and transitions will take place. <br /> |

### Scene

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Scene (ViewGroup sceneRoot, 
                View layout)
```

Constructs a Scene which, when entered, will remove any children from the sceneRoot container and add the layout object as a new child of that container.

<br />

|                                                       Parameters                                                        ||
|-------------|------------------------------------------------------------------------------------------------------------|
| `sceneRoot` | `ViewGroup`: The root of the hierarchy in which scene changes and transitions will take place. <br />      |
| `layout`    | `View`: The view hierarchy of this scene, added as a child of sceneRoot when this scene is entered. <br /> |

## Public methods

### enter

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void enter ()
```

Enters this scene, which entails changing all values that are specified by this scene. These may be values associated with a layout view group or layout resource file which will now be added to the scene root, or it may be values changed by an[setEnterAction(Runnable)](https://developer.android.com/reference/android/support/transition/Scene#setEnterAction(java.lang.Runnable))enter action}, or a combination of the these. No transition will be run when the scene is entered. To get transition behavior in scene changes, use one of the methods in[TransitionManager](https://developer.android.com/reference/android/support/transition/TransitionManager)instead.

<br />

### exit

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void exit ()
```

Exits this scene, if it is the current scene on the scene's[scene root](https://developer.android.com/reference/android/support/transition/Scene#getSceneRoot()). The current scene is set when[entering](https://developer.android.com/reference/android/support/transition/Scene#enter())a scene. Exiting a scene runs the[exit action](https://developer.android.com/reference/android/support/transition/Scene#setExitAction(java.lang.Runnable))if there is one.

<br />

### getSceneForLayout

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Scene getSceneForLayout (ViewGroup sceneRoot, 
                int layoutId, 
                Context context)
```

Returns a Scene described by the resource file associated with the given`layoutId`parameter. If such a Scene has already been created for the given`sceneRoot`, that same Scene will be returned. This caching of layoutId-based scenes enables sharing of common scenes between those created in code and those referenced by[TransitionManager](https://developer.android.com/reference/android/support/transition/TransitionManager)XML resource files.

<br />

|                                                     Parameters                                                     ||
|-------------|-------------------------------------------------------------------------------------------------------|
| `sceneRoot` | `ViewGroup`: The root of the hierarchy in which scene changes and transitions will take place. <br /> |
| `layoutId`  | `int`: The id of a standard layout resource file. <br />                                              |
| `context`   | `Context`: The context used in the process of inflating the layout resource. <br />                   |

|                                                               Returns                                                                ||
|-----------------------------------------------------------------------------------|---------------------------------------------------|
| [Scene](https://developer.android.com/reference/android/support/transition/Scene) | The scene for the given root and layout id <br /> |

### getSceneRoot

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ViewGroup getSceneRoot ()
```

Gets the root of the scene, which is the root of the view hierarchy affected by changes due to this scene, and which will be animated when this scene is entered.

<br />

|                                                                     Returns                                                                     ||
|----------------------------------------------------------------------------------|---------------------------------------------------------------|
| [ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html) | The root of the view hierarchy affected by this scene. <br /> |

### setEnterAction

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setEnterAction (Runnable action)
```

Scenes that are not defined with layout resources or hierarchies, or which need to perform additional steps after those hierarchies are changed to, should set an enter action, and possibly an exit action as well. An enter action will cause Scene to call back into application code to do anything else the application needs after transitions have captured pre-change values and after any other scene changes have been applied, such as the layout (if any) being added to the view hierarchy. After this method is called, Transitions will be played.

<br />

|                                                                                Parameters                                                                                ||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `action` | `Runnable`: The runnable whose[run()](https://developer.android.com/reference/java/lang/Runnable#run())method will be called when this scene is entered <br /> |

**See also:**

- [setExitAction(Runnable)](https://developer.android.com/reference/android/support/transition/Scene#setExitAction(java.lang.Runnable))
- [ERROR(/android.support.transition.Scene(android.view.ViewGroup, android.view.ViewGroup))](https://developer.android.com/)  

### setExitAction

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setExitAction (Runnable action)
```

Scenes that are not defined with layout resources or hierarchies, or which need to perform additional steps after those hierarchies are changed to, should set an enter action, and possibly an exit action as well. An exit action will cause Scene to call back into application code to do anything the application needs to do after applicable transitions have captured pre-change values, but before any other scene changes have been applied, such as the new layout (if any) being added to the view hierarchy. After this method is called, the next scene will be entered, including a call to[setEnterAction(Runnable)](https://developer.android.com/reference/android/support/transition/Scene#setEnterAction(java.lang.Runnable))if an enter action is set.

<br />

|         Parameters          ||
|----------|-------------------|
| `action` | `Runnable` <br /> |

**See also:**

- [setEnterAction(Runnable)](https://developer.android.com/reference/android/support/transition/Scene#setEnterAction(java.lang.Runnable))
- [ERROR(/android.support.transition.Scene(android.view.ViewGroup, android.view.ViewGroup))](https://developer.android.com/)  
-

  ## Interfaces

  - [Transition.TransitionListener](https://developer.android.com/reference/android/support/transition/Transition.TransitionListener)
-

  ## Classes

  - [ArcMotion](https://developer.android.com/reference/android/support/transition/ArcMotion)
  - [AutoTransition](https://developer.android.com/reference/android/support/transition/AutoTransition)
  - [ChangeBounds](https://developer.android.com/reference/android/support/transition/ChangeBounds)
  - [ChangeClipBounds](https://developer.android.com/reference/android/support/transition/ChangeClipBounds)
  - [ChangeImageTransform](https://developer.android.com/reference/android/support/transition/ChangeImageTransform)
  - [ChangeScroll](https://developer.android.com/reference/android/support/transition/ChangeScroll)
  - [ChangeTransform](https://developer.android.com/reference/android/support/transition/ChangeTransform)
  - [CircularPropagation](https://developer.android.com/reference/android/support/transition/CircularPropagation)
  - [Explode](https://developer.android.com/reference/android/support/transition/Explode)
  - [Fade](https://developer.android.com/reference/android/support/transition/Fade)
  - [PathMotion](https://developer.android.com/reference/android/support/transition/PathMotion)
  - [PatternPathMotion](https://developer.android.com/reference/android/support/transition/PatternPathMotion)
  - [R](https://developer.android.com/reference/android/support/transition/R)
  - [R.attr](https://developer.android.com/reference/android/support/transition/R.attr)
  - [R.bool](https://developer.android.com/reference/android/support/transition/R.bool)
  - [R.color](https://developer.android.com/reference/android/support/transition/R.color)
  - [R.dimen](https://developer.android.com/reference/android/support/transition/R.dimen)
  - [R.drawable](https://developer.android.com/reference/android/support/transition/R.drawable)
  - [R.id](https://developer.android.com/reference/android/support/transition/R.id)
  - [R.integer](https://developer.android.com/reference/android/support/transition/R.integer)
  - [R.layout](https://developer.android.com/reference/android/support/transition/R.layout)
  - [R.string](https://developer.android.com/reference/android/support/transition/R.string)
  - [R.style](https://developer.android.com/reference/android/support/transition/R.style)
  - [R.styleable](https://developer.android.com/reference/android/support/transition/R.styleable)
  - [Scene](https://developer.android.com/reference/android/support/transition/Scene)
  - [SidePropagation](https://developer.android.com/reference/android/support/transition/SidePropagation)
  - [Slide](https://developer.android.com/reference/android/support/transition/Slide)
  - [Transition](https://developer.android.com/reference/android/support/transition/Transition)
  - [Transition.EpicenterCallback](https://developer.android.com/reference/android/support/transition/Transition.EpicenterCallback)
  - [TransitionInflater](https://developer.android.com/reference/android/support/transition/TransitionInflater)
  - [TransitionListenerAdapter](https://developer.android.com/reference/android/support/transition/TransitionListenerAdapter)
  - [TransitionManager](https://developer.android.com/reference/android/support/transition/TransitionManager)
  - [TransitionPropagation](https://developer.android.com/reference/android/support/transition/TransitionPropagation)
  - [TransitionSet](https://developer.android.com/reference/android/support/transition/TransitionSet)
  - [TransitionValues](https://developer.android.com/reference/android/support/transition/TransitionValues)
  - [Visibility](https://developer.android.com/reference/android/support/transition/Visibility)
  - [VisibilityPropagation](https://developer.android.com/reference/android/support/transition/VisibilityPropagation)