# MotionLayout.TransitionListener

Artifact: [androidx.constraintlayout:constraintlayout](https://developer.android.com/jetpack/androidx/releases/constraintlayout) [View Source](https://cs.android.com/search?q=file:androidx/constraintlayout/motion/widget/MotionLayout.java+class:androidx.constraintlayout.motion.widget.MotionLayout.TransitionListener) Added in [2.2.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#2.2.2)

*** ** * ** ***


```
public interface MotionLayout.TransitionListener
```

<br />

Known direct subclasses [MotionHelperInterface](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionHelperInterface), [TransitionAdapter](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/TransitionAdapter)

|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionHelperInterface` | This defined the interface for MotionLayout helpers Helpers can be used to draw motion effects or modify motions |
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/TransitionAdapter` |   |

Known indirect subclasses [Carousel](https://developer.android.com/reference/androidx/constraintlayout/helper/widget/Carousel), [MotionEffect](https://developer.android.com/reference/androidx/constraintlayout/helper/widget/MotionEffect), [MotionHelper](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionHelper)

|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/helper/widget/Carousel` | Carousel works within a MotionLayout to provide a simple recycler like pattern. |
| `https://developer.android.com/reference/androidx/constraintlayout/helper/widget/MotionEffect` | MotionHelper that automatically inserts keyframes for views moving in a given direction, out of: |
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionHelper` |   |

*** ** * ** ***

Listener for monitoring events about TransitionLayout. **Added in 2.0**

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout.TransitionListener#onTransitionChange(androidx.constraintlayout.motion.widget.MotionLayout,int,int,float)( https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout motionLayout, int startId, int endId, float progress )` Called when a drawer's position changes. |
| `abstract void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout.TransitionListener#onTransitionCompleted(androidx.constraintlayout.motion.widget.MotionLayout,int)(https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout motionLayout, int currentId)` Called when a drawer has settled completely a state. |
| `abstract void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout.TransitionListener#onTransitionStarted(androidx.constraintlayout.motion.widget.MotionLayout,int,int)(https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout motionLayout, int startId, int endId)` Called when a drawer is about to start a transition. |
| `abstract void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout.TransitionListener#onTransitionTrigger(androidx.constraintlayout.motion.widget.MotionLayout,int,boolean,float)( https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout motionLayout, int triggerId, boolean positive, float progress )` Call when a trigger is fired |

## Public methods

### onTransitionChange

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

```
abstract void onTransitionChange(
    MotionLayout motionLayout,
    int startId,
    int endId,
    float progress
)
```

Called when a drawer's position changes.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout motionLayout` | The TransitionLayout view that was moved |
| `int startId` | the id of the start state (or ConstraintSet). Will be -1 if unknown. |
| `int endId` | the id of the end state (or ConstraintSet). |
| `float progress` | The progress on this transition, from 0 to 1. |

### onTransitionCompleted

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

```
abstract void onTransitionCompleted(MotionLayout motionLayout, int currentId)
```

Called when a drawer has settled completely a state. The TransitionLayout is interactive at this point.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout motionLayout` | Drawer view that is now open |
| `int currentId` | the id it has reached |

### onTransitionStarted

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

```
abstract void onTransitionStarted(MotionLayout motionLayout, int startId, int endId)
```

Called when a drawer is about to start a transition. Note. startId may be -1 if starting from an "undefined state"

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout motionLayout` | The TransitionLayout view that was moved |
| `int startId` | the id of the start state (or ConstraintSet). Will be -1 if unknown. |
| `int endId` | the id of the end state (or ConstraintSet). |

### onTransitionTrigger

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

```
abstract void onTransitionTrigger(
    MotionLayout motionLayout,
    int triggerId,
    boolean positive,
    float progress
)
```

Call when a trigger is fired

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout motionLayout` |   |
| `int triggerId` | The id set set with triggerID |
| `boolean positive` | for positive transition edge |
| `float progress` |   |