# MaterialContainerTransform

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/transition/MaterialContainerTransform.java)

*** ** * ** ***


```
public final class MaterialContainerTransform
```

<br />

*** ** * ** ***

A shared element Transition that transforms one container to another.

MaterialContainerTransform can be used to morph between two Activities, Fragments, Views or a View to a Fragment.

This transition captures a start and end View which are used to create a Drawable which will be added to the view hierarchy. The drawable will be added to the view hierarchy as an overlay and handles drawing a mask that morphs between the shape of the start View to the shape of the end View. During the animation, the start and end View's are drawn inside the masking container and faded in and/or out over a duration of the transition. Additionally, the masking container will be translated and scaled from the position and size of the start View to the position and size of the end View.

MaterialContainerTransform supports theme-based easing, duration, and path values. In order to have the transition load these values upfront, use the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#MaterialContainerTransform(Context,boolean)` constructor. Otherwise, use the default constructor and the transition will load theme values from the View context before it runs, and only use them if the corresponding properties weren't already set on the transition instance.

The composition of MaterialContainerTransform's animation can be customized in a number of ways. The two most prominent customizations are the way in which content inside the container is swapped via `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setFadeMode(int)` and path the container follows from its starting position to its ending position via `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setPathMotion(PathMotion)`. For other ways to customize the container transform, see:

| See also |
|---|---|
| `https://developer.android.com/reference/[JVM root]/setInterpolator(TimeInterpolator)` |   |
| `https://developer.android.com/reference/[JVM root]/setDuration(long)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartShapeAppearanceModel(com.google.android.material.shape.ShapeAppearanceModel)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndShapeAppearanceModel(com.google.android.material.shape.ShapeAppearanceModel)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setDrawingViewId(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setScrimColor(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setFadeMode(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setFitMode(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setPathMotion(PathMotion)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setFadeProgressThresholds(com.google.android.material.transition.MaterialContainerTransform.ProgressThresholds)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setScaleProgressThresholds(com.google.android.material.transition.MaterialContainerTransform.ProgressThresholds)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setScaleMaskProgressThresholds(com.google.android.material.transition.MaterialContainerTransform.ProgressThresholds)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setShapeMaskProgressThresholds(com.google.android.material.transition.MaterialContainerTransform.ProgressThresholds)` |   |

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` A class which holds a start and end value which represent a range within 0.0 - 1.0. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FADE_MODE_CROSS() = 2` Indicates that this transition should cross fade the outgoing and incoming content. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FADE_MODE_IN() = 0` Indicates that this transition should only fade in the incoming content, without changing the opacity of the outgoing content. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FADE_MODE_OUT() = 1` Indicates that this transition should only fade out the outgoing content, without changing the opacity of the incoming content. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FADE_MODE_THROUGH() = 3` Indicates that this transition should sequentially fade out the outgoing content and fade in the incoming content. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FIT_MODE_AUTO() = 0` Indicates that this transition should automatically choose whether to use `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FIT_MODE_WIDTH()` or `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FIT_MODE_HEIGHT()`. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FIT_MODE_HEIGHT() = 2` Indicates that this transition should fit the incoming content to the height of the outgoing content during the scale animation. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FIT_MODE_WIDTH() = 1` Indicates that this transition should fit the incoming content to the width of the outgoing content during the scale animation. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#TRANSITION_DIRECTION_AUTO() = 0` Indicates that this transition should use automatic detection to determine whether it is an Enter or a Return. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#TRANSITION_DIRECTION_ENTER() = 1` Indicates that this is an Enter transition, i.e., when elements are entering the scene. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#TRANSITION_DIRECTION_RETURN() = 2` Indicates that this is a Return transition, i.e., when elements are exiting the scene. |

| ### Public fields |
|---|---|
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#containerColor()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#drawingViewId()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#endContainerColor()` |
| `float` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#endElevation()` |
| `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#endShapeAppearanceModel()` |
| `View` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#endView()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#endViewId()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#fadeMode()` |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#fadeProgressThresholds()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#fitMode()` |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#scaleMaskProgressThresholds()` |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#scaleProgressThresholds()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#scrimColor()` |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#shapeMaskProgressThresholds()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#startContainerColor()` |
| `float` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#startElevation()` |
| `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#startShapeAppearanceModel()` |
| `View` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#startView()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#startViewId()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#transitionDirection()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#MaterialContainerTransform()()` |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#MaterialContainerTransform(Context,boolean)(Context context, boolean entering)` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#captureEndValues(TransitionValues)(TransitionValues transitionValues)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#captureStartValues(TransitionValues)(TransitionValues transitionValues)` |
| `Animator` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#createAnimator(ViewGroup,TransitionValues,TransitionValues)( ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues )` |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getContainerColor()()` Get the color to be drawn beneath both the start view and end view. |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getDrawingViewId()()` Get the id of the View whose overlay this transitions will be added to. |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getEndContainerColor()()` Get the color to be drawn beneath the end view. |
| `float` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getEndElevation()()` Get the elevation that will be used to render a shadow around the container at the end of the transition. |
| `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getEndShapeAppearanceModel()()` Get the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` which will be used to determine the shape into which the container will be transformed. |
| `View` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getEndView()()` Get the View which will be used as the end shared element container. |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getEndViewId()()` Get the id of the View which will be used as the end shared element container. |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getFadeMode()()` The fade mode to be used to swap the content of the start View with that of the end View. |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getFadeProgressThresholds()()` Get the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 - 1.0) between which the fade animation, determined by `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getFadeMode()` will complete. |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getFitMode()()` The fit mode to be used when scaling the incoming content of the end View. |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getScaleMaskProgressThresholds()()` Get the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 and 1.0) between which the container will morph between the start and end View's dimensions. |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getScaleProgressThresholds()()` Get the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 - 1.0) between which the outgoing and incoming content will scale to the full dimensions of the end container. |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getScrimColor()()` Get the color to be drawn under the morphing container but within the bounds of the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getDrawingViewId()`. |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getShapeMaskProgressThresholds()()` Get the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 and 1.0) between which the container will morph between the starting `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` and ending `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel`. |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getStartContainerColor()()` Get the color to be drawn beneath the start view. |
| `float` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getStartElevation()()` Get the elevation that will be used to render a shadow around the container at the start of the transition. |
| `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getStartShapeAppearanceModel()()` Get the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` which will be used to determine the shape from which the container will be transformed. |
| `View` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getStartView()()` Get the View which will be used as the start shared element container. |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getStartViewId()()` Get the id of the View which will be used as the start shared element container. |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getTransitionDirection()()` The direction to be used by this transform. |
| `String[]` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getTransitionProperties()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#isDrawDebugEnabled()()` Whether debug drawing is enabled. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#isElevationShadowEnabled()()` Get whether shadows should be drawn around the container to approximate native elevation shadows on the start and end views. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#isHoldAtEndEnabled()()` Whether to hold the last frame at the end of the animation. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setAllContainerColors(int)(int containerColor)` Set the container color, the start container color and the end container color. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setContainerColor(int)(int containerColor)` Set a color to be drawn beneath both the start and end view. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setDrawDebugEnabled(boolean)(boolean drawDebugEnabled)` Set whether or not to draw paths which follow the shape and path of animating containers. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setDrawingViewId(int)(int drawingViewId)` Set the id of the View whose overlay this transition will be added to. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setElevationShadowEnabled(boolean)(boolean elevationShadowEnabled)` Set whether shadows should be drawn around the container to approximate native elevation shadows on the start and end views. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndContainerColor(int)(int containerColor)` Set a color to be drawn beneath the end view. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndElevation(float)(float endElevation)` Set the elevation that will be used to render a shadow around the container at the end of the transition. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndShapeAppearanceModel(com.google.android.material.shape.ShapeAppearanceModel)( https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel endShapeAppearanceModel )` Set the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` which will be used to determine the shape into which the container will be transformed. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndView(View)(View endView)` Set the View to be used as the end shared element container. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndViewId(int)(int endViewId)` Set the id of the View to be used as the end shared element container. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setFadeMode(int)(int fadeMode)` Set the fade mode to be used to swap the content of the start View with that of the end View. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setFadeProgressThresholds(com.google.android.material.transition.MaterialContainerTransform.ProgressThresholds)( https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds fadeProgressThresholds )` Set the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 - 1.0) between which the fade animation, determined by `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getFadeMode()` will complete. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setFitMode(int)(int fitMode)` Set the fit mode to be used when scaling the incoming content of the end View. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setHoldAtEndEnabled(boolean)(boolean holdAtEndEnabled)` If true, the last frame of the animation will be held in place, and the original outgoing and incoming views will not be re-shown. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setPathMotion(PathMotion)(PathMotion pathMotion)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setScaleMaskProgressThresholds(com.google.android.material.transition.MaterialContainerTransform.ProgressThresholds)( https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds scaleMaskProgressThresholds )` Set the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 and 1.0) between which the container will morph between the start and end View's dimensions. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setScaleProgressThresholds(com.google.android.material.transition.MaterialContainerTransform.ProgressThresholds)( https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds scaleProgressThresholds )` Set the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 - 1.0) between which the outgoing and incoming content will scale to the full dimensions of the end container. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setScrimColor(int)(int scrimColor)` Set the color to be drawn under the morphing container but within the bounds of the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getDrawingViewId()`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setShapeMaskProgressThresholds(com.google.android.material.transition.MaterialContainerTransform.ProgressThresholds)( https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds shapeMaskProgressThresholds )` Set the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 and 1.0) between which the container will morph between the starting `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` and ending `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartContainerColor(int)(int containerColor)` Set a color to be drawn beneath the start view. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartElevation(float)(float startElevation)` Set the elevation that will be used to render a shadow around the container at the start of the transition. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartShapeAppearanceModel(com.google.android.material.shape.ShapeAppearanceModel)( https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel startShapeAppearanceModel )` Set the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` which will be used to determine the shape from which the container will be transformed. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartView(View)(View startView)` Set the View to be used as the start shared element container. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartViewId(int)(int startViewId)` Set the id of the View to be used as the start shared element container. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setTransitionDirection(int)(int transitionDirection)` Set the transition direction to be used by this transform. |

## Constants

### FADE_MODE_CROSS

```
public static final int FADE_MODE_CROSS = 2
```

Indicates that this transition should cross fade the outgoing and incoming content.

### FADE_MODE_IN

```
public static final int FADE_MODE_IN = 0
```

Indicates that this transition should only fade in the incoming content, without changing the opacity of the outgoing content.

### FADE_MODE_OUT

```
public static final int FADE_MODE_OUT = 1
```

Indicates that this transition should only fade out the outgoing content, without changing the opacity of the incoming content.

### FADE_MODE_THROUGH

```
public static final int FADE_MODE_THROUGH = 3
```

Indicates that this transition should sequentially fade out the outgoing content and fade in the incoming content.

### FIT_MODE_AUTO

```
public static final int FIT_MODE_AUTO = 0
```

Indicates that this transition should automatically choose whether to use `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FIT_MODE_WIDTH()` or `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FIT_MODE_HEIGHT()`.

### FIT_MODE_HEIGHT

```
public static final int FIT_MODE_HEIGHT = 2
```

Indicates that this transition should fit the incoming content to the height of the outgoing content during the scale animation.

### FIT_MODE_WIDTH

```
public static final int FIT_MODE_WIDTH = 1
```

Indicates that this transition should fit the incoming content to the width of the outgoing content during the scale animation.

### TRANSITION_DIRECTION_AUTO

```
public static final int TRANSITION_DIRECTION_AUTO = 0
```

Indicates that this transition should use automatic detection to determine whether it is an Enter or a Return. If the end container has a larger area than the start container then it is considered an Enter transition, otherwise it is a Return transition.

### TRANSITION_DIRECTION_ENTER

```
public static final int TRANSITION_DIRECTION_ENTER = 1
```

Indicates that this is an Enter transition, i.e., when elements are entering the scene.

### TRANSITION_DIRECTION_RETURN

```
public static final int TRANSITION_DIRECTION_RETURN = 2
```

Indicates that this is a Return transition, i.e., when elements are exiting the scene.

## Public fields

### containerColor

```
public int containerColor
```

### drawingViewId

```
public int drawingViewId
```

### endContainerColor

```
public int endContainerColor
```

### endElevation

```
public float endElevation
```

### endShapeAppearanceModel

```
public ShapeAppearanceModel endShapeAppearanceModel
```

### endView

```
public View endView
```

### endViewId

```
public int endViewId
```

### fadeMode

```
public int fadeMode
```

### fadeProgressThresholds

```
public MaterialContainerTransform.ProgressThresholds fadeProgressThresholds
```

### fitMode

```
public int fitMode
```

### scaleMaskProgressThresholds

```
public MaterialContainerTransform.ProgressThresholds scaleMaskProgressThresholds
```

### scaleProgressThresholds

```
public MaterialContainerTransform.ProgressThresholds scaleProgressThresholds
```

### scrimColor

```
public int scrimColor
```

### shapeMaskProgressThresholds

```
public MaterialContainerTransform.ProgressThresholds shapeMaskProgressThresholds
```

### startContainerColor

```
public int startContainerColor
```

### startElevation

```
public float startElevation
```

### startShapeAppearanceModel

```
public ShapeAppearanceModel startShapeAppearanceModel
```

### startView

```
public View startView
```

### startViewId

```
public int startViewId
```

### transitionDirection

```
public int transitionDirection
```

## Public constructors

### MaterialContainerTransform

```
public MaterialContainerTransform()
```

### MaterialContainerTransform

```
public MaterialContainerTransform(Context context, boolean entering)
```

## Public methods

### captureEndValues

```
public void captureEndValues(TransitionValues transitionValues)
```

### captureStartValues

```
public void captureStartValues(TransitionValues transitionValues)
```

### createAnimator

```
public Animator createAnimator(
    ViewGroup sceneRoot,
    TransitionValues startValues,
    TransitionValues endValues
)
```

### getContainerColor

```
public int getContainerColor()
```

Get the color to be drawn beneath both the start view and end view.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setContainerColor(int)` |   |

### getDrawingViewId

```
public int getDrawingViewId()
```

Get the id of the View whose overlay this transitions will be added to.

### getEndContainerColor

```
public int getEndContainerColor()
```

Get the color to be drawn beneath the end view.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndContainerColor(int)` |   |

### getEndElevation

```
public float getEndElevation()
```

Get the elevation that will be used to render a shadow around the container at the end of the transition.

Default is -1, which means the elevation of the end view will be used.

### getEndShapeAppearanceModel

```
public ShapeAppearanceModel getEndShapeAppearanceModel()
```

Get the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` which will be used to determine the shape into which the container will be transformed.

### getEndView

```
public View getEndView()
```

Get the View which will be used as the end shared element container.

### getEndViewId

```
public int getEndViewId()
```

Get the id of the View which will be used as the end shared element container.

Setting an end View id can be used to manually configure MaterialContainerTransform when transitioning between two Views in a single layout when the Transition system will not automatically capture shared element start or end Views for you.

If the end view cannot be found during the initialization of the `
MaterialContainerTransform`, then an `https://developer.android.com/reference/java/lang/IllegalArgumentException` will be thrown.

### getFadeMode

```
public int getFadeMode()
```

The fade mode to be used to swap the content of the start View with that of the end View.

### getFadeProgressThresholds

```
public MaterialContainerTransform.ProgressThresholds getFadeProgressThresholds()
```

Get the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 - 1.0) between which the fade animation, determined by `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getFadeMode()` will complete.

### getFitMode

```
public int getFitMode()
```

The fit mode to be used when scaling the incoming content of the end View.

### getScaleMaskProgressThresholds

```
public MaterialContainerTransform.ProgressThresholds getScaleMaskProgressThresholds()
```

Get the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 and 1.0) between which the container will morph between the start and end View's dimensions.

### getScaleProgressThresholds

```
public MaterialContainerTransform.ProgressThresholds getScaleProgressThresholds()
```

Get the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 - 1.0) between which the outgoing and incoming content will scale to the full dimensions of the end container.

### getScrimColor

```
public int getScrimColor()
```

Get the color to be drawn under the morphing container but within the bounds of the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getDrawingViewId()`.

### getShapeMaskProgressThresholds

```
public MaterialContainerTransform.ProgressThresholds getShapeMaskProgressThresholds()
```

Get the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 and 1.0) between which the container will morph between the starting `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` and ending `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel`.

### getStartContainerColor

```
public int getStartContainerColor()
```

Get the color to be drawn beneath the start view.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartContainerColor(int)` |   |

### getStartElevation

```
public float getStartElevation()
```

Get the elevation that will be used to render a shadow around the container at the start of the transition.

Default is -1, which means the elevation of the start view will be used.

### getStartShapeAppearanceModel

```
public ShapeAppearanceModel getStartShapeAppearanceModel()
```

Get the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` which will be used to determine the shape from which the container will be transformed.

### getStartView

```
public View getStartView()
```

Get the View which will be used as the start shared element container.

### getStartViewId

```
public int getStartViewId()
```

Get the id of the View which will be used as the start shared element container.

### getTransitionDirection

```
public int getTransitionDirection()
```

The direction to be used by this transform.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#TRANSITION_DIRECTION_AUTO()` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#TRANSITION_DIRECTION_ENTER()` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#TRANSITION_DIRECTION_RETURN()` |   |

### getTransitionProperties

```
public String[] getTransitionProperties()
```

### isDrawDebugEnabled

```
public boolean isDrawDebugEnabled()
```

Whether debug drawing is enabled.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setDrawDebugEnabled(boolean)` |   |

### isElevationShadowEnabled

```
public boolean isElevationShadowEnabled()
```

Get whether shadows should be drawn around the container to approximate native elevation shadows on the start and end views.

### isHoldAtEndEnabled

```
public boolean isHoldAtEndEnabled()
```

Whether to hold the last frame at the end of the animation.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setHoldAtEndEnabled(boolean)` |   |

### setAllContainerColors

```
public void setAllContainerColors(int containerColor)
```

Set the container color, the start container color and the end container color.

This is a helper for the common case of transitioning between a start and end view when neither draws its own background but a common color is shared. This prevents the start or end view from being visible below one another.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setContainerColor(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartContainerColor(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndContainerColor(int)` |   |

### setContainerColor

```
public void setContainerColor(int containerColor)
```

Set a color to be drawn beneath both the start and end view.

This color is the background color of the transforming container inside of which the start and end views are drawn. Unlike the start view, start container color, end view and end container color, this color will always be drawn as fully opaque, beneath all other content in the container. By default, this color is set to transparent (0), meaning a container color will not be drawn.

If a default container transform results in the start view being visible beneath the end view, or vica versa, this is due to one or both views not having a background. The most common way to solve this issue is by sequentially fading the contents with `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FADE_MODE_THROUGH()` and setting this color to the start and end view's desired background color.

If the start and end views have different background colors, or you would like to use a fade mode other than `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FADE_MODE_THROUGH()`, handle this by using `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartContainerColor(int)` and `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndContainerColor(int)`.

### setDrawDebugEnabled

```
public void setDrawDebugEnabled(boolean drawDebugEnabled)
```

Set whether or not to draw paths which follow the shape and path of animating containers.

| Parameters |
|---|---|
| `boolean drawDebugEnabled` | true if debugging lines and borders should be drawn during animation. |

### setDrawingViewId

```
public void setDrawingViewId(int drawingViewId)
```

Set the id of the View whose overlay this transition will be added to.

This can be used to limit the bounds of the animation (including the background scrim) to the bounds of the provided drawing view, and also have the animation drawn at the relative z-order of the drawing view.

By default, the `drawingViewId` will be `android.R.id.content`. Additionally, if `drawingViewId` is the same as the end View's id, `MaterialContainerTransform` will add the transition's drawable to the `drawingViewId`'s parent instead.

If the drawing view cannot be found during the initialization of the `
MaterialContainerTransform`, then an `https://developer.android.com/reference/java/lang/IllegalArgumentException` will be thrown.

### setElevationShadowEnabled

```
public void setElevationShadowEnabled(boolean elevationShadowEnabled)
```

Set whether shadows should be drawn around the container to approximate native elevation shadows on the start and end views.

By default, the elevation shadows are only enabled for API level 28 and above, because Paint shadows are not supported with hardware acceleration below API level 28. If enabled for below API level 28, then the shadows will be drawn using `https://developer.android.com/reference/com/google/android/material/shape/MaterialShapeDrawable`, however this may cause performance issues.

Additionally, the rendering of elevation shadows may cause performance issues if the container's shape is not a round rect or a regular rect, e.g., a rect with cut corners.

### setEndContainerColor

```
public void setEndContainerColor(int containerColor)
```

Set a color to be drawn beneath the end view.

This color will be drawn directly beneath the end view, will fill the entire transforming container, and the will animate its opacity to match the end view's. By default, this color is set to transparent (0), meaning no color will be drawn.

This method can be useful when the color of the start and end view differ and the end view does not handle drawing its own background. Setting this color will prevent the start view from being visible beneath the end view while transforming.

### setEndElevation

```
public void setEndElevation(float endElevation)
```

Set the elevation that will be used to render a shadow around the container at the end of the transition.

By default the elevation of the end view will be used.

### setEndShapeAppearanceModel

```
public void setEndShapeAppearanceModel(
    ShapeAppearanceModel endShapeAppearanceModel
)
```

Set the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` which will be used to determine the shape into which the container will be transformed.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartShapeAppearanceModel(com.google.android.material.shape.ShapeAppearanceModel)` |   |

### setEndView

```
public void setEndView(View endView)
```

Set the View to be used as the end shared element container.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndViewId(int)` |   |

### setEndViewId

```
public void setEndViewId(int endViewId)
```

Set the id of the View to be used as the end shared element container. The matching View will be searched for in the hierarchy when starting this transition.

Manually setting the end View id will override any View explicitly set via `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndView(View)` or any View picked up by the Transition system marked with a transitionName.

### setFadeMode

```
public void setFadeMode(int fadeMode)
```

Set the fade mode to be used to swap the content of the start View with that of the end View.

By default, the fade mode is set to `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FADE_MODE_IN()`.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FADE_MODE_IN()` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FADE_MODE_OUT()` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FADE_MODE_CROSS()` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FADE_MODE_THROUGH()` |   |

### setFadeProgressThresholds

```
public void setFadeProgressThresholds(
    MaterialContainerTransform.ProgressThresholds fadeProgressThresholds
)
```

Set the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 - 1.0) between which the fade animation, determined by `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getFadeMode()` will complete.

See `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` for an example of how the threshold ranges work.

### setFitMode

```
public void setFitMode(int fitMode)
```

Set the fit mode to be used when scaling the incoming content of the end View.

By default, the fit mode is set to `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#FIT_MODE_AUTO()`.

### setHoldAtEndEnabled

```
public void setHoldAtEndEnabled(boolean holdAtEndEnabled)
```

If true, the last frame of the animation will be held in place, and the original outgoing and incoming views will not be re-shown.

Useful for Activity return transitions to make sure the screen doesn't flash at the end.

### setPathMotion

```
public void setPathMotion(PathMotion pathMotion)
```

### setScaleMaskProgressThresholds

```
public void setScaleMaskProgressThresholds(
    MaterialContainerTransform.ProgressThresholds scaleMaskProgressThresholds
)
```

Set the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 and 1.0) between which the container will morph between the start and end View's dimensions.

See `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` for an example of how the threshold ranges work.

### setScaleProgressThresholds

```
public void setScaleProgressThresholds(
    MaterialContainerTransform.ProgressThresholds scaleProgressThresholds
)
```

Set the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 - 1.0) between which the outgoing and incoming content will scale to the full dimensions of the end container.

See `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` for an example of how the threshold ranges work.

### setScrimColor

```
public void setScrimColor(int scrimColor)
```

Set the color to be drawn under the morphing container but within the bounds of the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#getDrawingViewId()`.

By default this is set to black with 32% opacity. Drawing a scrim is primarily useful for transforming from a partial-screen View (eg. Card in a grid) to a full screen. The scrim will gradually fade in and cover the content being transformed over by the morphing container.

Changing the default scrim color can be useful when transitioning between two Views in a layout, where the ending View does not cover any outgoing content (eg. a FAB to a bottom toolbar). For scenarios such as these, set the scrim color to transparent.

### setShapeMaskProgressThresholds

```
public void setShapeMaskProgressThresholds(
    MaterialContainerTransform.ProgressThresholds shapeMaskProgressThresholds
)
```

Set the `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` which define the sub-range (any range inside the full progress range of 0.0 and 1.0) between which the container will morph between the starting `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` and ending `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel`.

See `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform.ProgressThresholds` for an example of how the threshold ranges work.

### setStartContainerColor

```
public void setStartContainerColor(int containerColor)
```

Set a color to be drawn beneath the start view.

This color will be drawn directly beneath the start view, will fill the entire transforming container, and will animate its opacity to match the start view's. By default, this color is set to transparent (0), meaning no color will be drawn.

This method can be useful when the color of the start and end view differ and the start view does not handle drawing its own background. This can also be used if an expanding container is larger than the start view. Setting this color to match that of the start view's background will cause the start view to look like its background is expanding to fill the transforming container.

### setStartElevation

```
public void setStartElevation(float startElevation)
```

Set the elevation that will be used to render a shadow around the container at the start of the transition.

By default the elevation of the start view will be used.

### setStartShapeAppearanceModel

```
public void setStartShapeAppearanceModel(
    ShapeAppearanceModel startShapeAppearanceModel
)
```

Set the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` which will be used to determine the shape from which the container will be transformed.

Manually setting a shape appearance will override both your theme's transitionShapeAppearance attribute (if set) and the shape appearance of the start View (or end View via `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setEndShapeAppearanceModel(com.google.android.material.shape.ShapeAppearanceModel)` if the View implements the `https://developer.android.com/reference/com/google/android/material/shape/Shapeable` interface. Setting this property can be useful if your start or end View does not implement `https://developer.android.com/reference/com/google/android/material/shape/Shapeable` but does have a shape (eg. a rounded rect background drawable) and you would like MaterialContainerTransform to morph from or to your View's shape.

### setStartView

```
public void setStartView(View startView)
```

Set the View to be used as the start shared element container.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartViewId(int)` |   |

### setStartViewId

```
public void setStartViewId(int startViewId)
```

Set the id of the View to be used as the start shared element container. The matching View will be searched for in the hierarchy when starting this transition.

Setting a start View can be helpful when transitioning from a View to another View or if transitioning from a View to a Fragment.

Manually setting the start View id will override any View explicitly set via `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#setStartView(View)` or any View picked up by the Transition system marked with a transitionName.

If the start view cannot be found during the initialization of the `
MaterialContainerTransform`, then an `https://developer.android.com/reference/java/lang/IllegalArgumentException` will be thrown.

### setTransitionDirection

```
public void setTransitionDirection(int transitionDirection)
```

Set the transition direction to be used by this transform.

By default, the transition direction is determined by the change in size between the start and end Views.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform#TRANSITION_DIRECTION_AUTO()` |   |