Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/transition/Scene#pubctors) \| [Methods](https://developer.android.com/reference/android/transition/Scene#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/transition/Scene#inhmethods)

# Scene

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/transition/Scene "View this page in Kotlin") \|Java


`
public

final

class
Scene
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.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 ||
|---|---|
| ` https://developer.android.com/reference/android/transition/Scene#Scene(android.view.ViewGroup)(https://developer.android.com/reference/android/view/ViewGroup sceneRoot) ` Constructs a Scene with no information about how values will change when this scene is applied. |
| ` https://developer.android.com/reference/android/transition/Scene#Scene(android.view.ViewGroup,%20android.view.View)(https://developer.android.com/reference/android/view/ViewGroup sceneRoot, https://developer.android.com/reference/android/view/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. |
| ` https://developer.android.com/reference/android/transition/Scene#Scene(android.view.ViewGroup,%20android.view.ViewGroup)(https://developer.android.com/reference/android/view/ViewGroup sceneRoot, https://developer.android.com/reference/android/view/ViewGroup layout) ` *This constructor is deprecated. use `https://developer.android.com/reference/android/transition/Scene#Scene(android.view.ViewGroup,%20android.view.View)`.* |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/transition/Scene#enter()() ` Enters this scene, which entails changing all values that are specified by this scene. |
| ` void` | ` https://developer.android.com/reference/android/transition/Scene#exit()() ` Exits this scene, if it is the current scene on the scene's `https://developer.android.com/reference/android/transition/Scene#getSceneRoot()`. |
| ` static https://developer.android.com/reference/android/transition/Scene` | ` https://developer.android.com/reference/android/transition/Scene#getCurrentScene(android.view.ViewGroup)(https://developer.android.com/reference/android/view/ViewGroup sceneRoot) ` Gets the current `https://developer.android.com/reference/android/transition/Scene` set on the given ViewGroup. |
| ` static https://developer.android.com/reference/android/transition/Scene` | ` https://developer.android.com/reference/android/transition/Scene#getSceneForLayout(android.view.ViewGroup,%20int,%20android.content.Context)(https://developer.android.com/reference/android/view/ViewGroup sceneRoot, int layoutId, https://developer.android.com/reference/android/content/Context context) ` Returns a Scene described by the resource file associated with the given `layoutId` parameter. |
| ` https://developer.android.com/reference/android/view/ViewGroup` | ` https://developer.android.com/reference/android/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` | ` https://developer.android.com/reference/android/transition/Scene#setEnterAction(java.lang.Runnable)(https://developer.android.com/reference/java/lang/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` | ` https://developer.android.com/reference/android/transition/Scene#setExitAction(java.lang.Runnable)(https://developer.android.com/reference/java/lang/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 |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### Scene

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public 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 `https://developer.android.com/reference/android/transition/Scene#setEnterAction(java.lang.Runnable)` and possibly
`https://developer.android.com/reference/android/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 [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public 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 /> |

### Scene

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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


**This constructor is deprecated.**   

use `https://developer.android.com/reference/android/transition/Scene#Scene(android.view.ViewGroup,%20android.view.View)`.

<br />

<br />

| Parameters ||
|---|---|
| `sceneRoot` | `ViewGroup` <br /> |
| `layout` | `ViewGroup` <br /> |

## Public methods

### enter

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public 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 `https://developer.android.com/reference/android/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 `https://developer.android.com/reference/android/transition/TransitionManager` instead.

<br />

### exit

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void exit ()
```

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

<br />

### getCurrentScene

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Scene getCurrentScene (ViewGroup sceneRoot)
```

Gets the current `https://developer.android.com/reference/android/transition/Scene` set on the given ViewGroup. A scene is set on a ViewGroup
only if that ViewGroup is the scene root.

<br />

| Parameters ||
|---|---|
| `sceneRoot` | `ViewGroup`: The ViewGroup on which the current scene will be returned. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/transition/Scene` | The current Scene set on this ViewGroup. A value of null indicates that no Scene is currently set. <br /> |

### getSceneForLayout

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static 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 `https://developer.android.com/reference/android/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 ||
|---|---|
| `https://developer.android.com/reference/android/transition/Scene` | The scene for the given root and layout id <br /> |

### getSceneRoot

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public 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 ||
|---|---|
| `https://developer.android.com/reference/android/view/ViewGroup` | The root of the view hierarchy affected by this scene. <br /> |

### setEnterAction

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public 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 `https://developer.android.com/reference/java/lang/Runnable#run()` method will be called when this scene is entered <br /> |

**See also:**

- `https://developer.android.com/reference/android/transition/Scene#setExitAction(java.lang.Runnable)`
- `https://developer.android.com/reference/android/transition/Scene#Scene(android.view.ViewGroup,%20android.view.View)`

### setExitAction

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public 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 `https://developer.android.com/reference/android/transition/Scene#setEnterAction(java.lang.Runnable)`
if an enter action is set.

<br />

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

**See also:**

- `https://developer.android.com/reference/android/transition/Scene#setEnterAction(java.lang.Runnable)`
- `https://developer.android.com/reference/android/transition/Scene#Scene(android.view.ViewGroup,%20android.view.View)`