# Transition

Artifact: [androidx.constraintlayout:constraintlayout-core](https://developer.android.com/jetpack/androidx/releases/constraintlayout) [View Source](https://cs.android.com/search?q=file:androidx/constraintlayout/core/state/Transition.java+class:androidx.constraintlayout.core.state.Transition) Added in [1.1.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#1.1.2)

*** ** * ** ***


```
public class Transition implements TypedValues
```

<br />

*** ** * ** ***

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition.WidgetState` |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#END() = 1` |
| `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#INTERPOLATED() = 2` |
| `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#START() = 0` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#Transition(androidx.constraintlayout.core.state.CorePixelDp)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/constraintlayout/core/state/CorePixelDp dpToPixel)` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#addCustomColor(int,java.lang.String,java.lang.String,int)(int state, https://developer.android.com/reference/java/lang/String.html widgetId, https://developer.android.com/reference/java/lang/String.html property, int color)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#addCustomFloat(int,java.lang.String,java.lang.String,float)(int state, https://developer.android.com/reference/java/lang/String.html widgetId, https://developer.android.com/reference/java/lang/String.html property, float value)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#addKeyAttribute(java.lang.String,androidx.constraintlayout.core.motion.utils.TypedBundle)(https://developer.android.com/reference/java/lang/String.html target, https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedBundle bundle)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#addKeyAttribute(java.lang.String,androidx.constraintlayout.core.motion.utils.TypedBundle,androidx.constraintlayout.core.motion.CustomVariable[])( https://developer.android.com/reference/java/lang/String.html target, https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedBundle bundle, CustomVariable[] custom )` Add a key attribute and the custom variables into the |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#addKeyCycle(java.lang.String,androidx.constraintlayout.core.motion.utils.TypedBundle)(https://developer.android.com/reference/java/lang/String.html target, https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedBundle bundle)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#addKeyPosition(java.lang.String,androidx.constraintlayout.core.motion.utils.TypedBundle)(https://developer.android.com/reference/java/lang/String.html target, https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedBundle bundle)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#addKeyPosition(java.lang.String,int,int,float,float)(https://developer.android.com/reference/java/lang/String.html target, int frame, int type, float x, float y)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#calcStagger()()` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#clear()()` |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#contains(java.lang.String)(https://developer.android.com/reference/java/lang/String.html key)` |
| `float` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#dragToProgress(float,int,int,float,float)( float currentProgress, int baseW, int baseH, float dx, float dy )` Converts from xy drag to progress This should be used till touch up |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#fillKeyPositions(androidx.constraintlayout.core.state.WidgetFrame,float[],float[],float[])(https://developer.android.com/reference/androidx/constraintlayout/core/state/WidgetFrame frame, float[] x, float[] y, float[] pos)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition.KeyPosition` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#findNextPosition(java.lang.String,int)(https://developer.android.com/reference/java/lang/String.html target, int frameNumber)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition.KeyPosition` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#findPreviousPosition(java.lang.String,int)(https://developer.android.com/reference/java/lang/String.html target, int frameNumber)` |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getAutoTransition()()` This gets the auto transition mode being used |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/WidgetFrame` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getEnd(androidx.constraintlayout.core.widgets.ConstraintWidget)(https://developer.android.com/reference/androidx/constraintlayout/core/widgets/ConstraintWidget child)` Used in debug draw |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/WidgetFrame` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getEnd(java.lang.String)(https://developer.android.com/reference/java/lang/String.html id)` |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getId(java.lang.String)(https://developer.android.com/reference/java/lang/String.html name)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/WidgetFrame` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getInterpolated(androidx.constraintlayout.core.widgets.ConstraintWidget)(https://developer.android.com/reference/androidx/constraintlayout/core/widgets/ConstraintWidget child)` Used after the interpolation |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/WidgetFrame` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getInterpolated(java.lang.String)(https://developer.android.com/reference/java/lang/String.html id)` |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getInterpolatedHeight()()` |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getInterpolatedWidth()()` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/Interpolator` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getInterpolator()()` This gets the interpolator being used |
| `static https://developer.android.com/reference/androidx/constraintlayout/core/state/Interpolator` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getInterpolator(int,java.lang.String)(int interpolator, https://developer.android.com/reference/java/lang/String.html interpolatorString)` get the interpolater based on a constant or a string |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getKeyFrames(java.lang.String,float[],int[],int[])( https://developer.android.com/reference/java/lang/String.html id, float[] rectangles, int[] pathMode, int[] position )` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/motion/Motion` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getMotion(java.lang.String)(https://developer.android.com/reference/java/lang/String.html id)` |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getNumberKeyPositions(androidx.constraintlayout.core.state.WidgetFrame)(https://developer.android.com/reference/androidx/constraintlayout/core/state/WidgetFrame frame)` |
| `float[]` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getPath(java.lang.String)(https://developer.android.com/reference/java/lang/String.html id)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/WidgetFrame` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getStart(androidx.constraintlayout.core.widgets.ConstraintWidget)(https://developer.android.com/reference/androidx/constraintlayout/core/widgets/ConstraintWidget child)` Used in debug draw |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/WidgetFrame` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getStart(java.lang.String)(https://developer.android.com/reference/java/lang/String.html id)` |
| `float` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getTouchUpProgress(long)(long currentTime)` get the current touch up progress current time in nanoseconds (ideally coming from an animation clock) |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition.WidgetState` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#getWidgetState(java.lang.String,androidx.constraintlayout.core.widgets.ConstraintWidget,int)( https://developer.android.com/reference/java/lang/String.html widgetId, https://developer.android.com/reference/androidx/constraintlayout/core/widgets/ConstraintWidget child, int transitionState )` |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#hasOnSwipe()()` |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#hasPositionKeyframes()()` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#interpolate(int,int,float)(int parentWidth, int parentHeight, float progress)` |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#isEmpty()()` |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#isTouchNotDone(float)(float currentProgress)` Are we still animating |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#setTouchUp(float,long,float,float)( float currentProgress, long currentTime, float velocityX, float velocityY )` Set the start of the touch up |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#setTransitionProperties(androidx.constraintlayout.core.motion.utils.TypedBundle)(https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedBundle bundle)` |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#setValue(int,boolean)(int id, boolean value)` Used to set boolean values |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#setValue(int,float)(int id, float value)` Used to set float values |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#setValue(int,int)(int id, int value)` Used to set integer values |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#setValue(int,java.lang.String)(int id, https://developer.android.com/reference/java/lang/String.html value)` Used to set String values |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/Transition#updateFrom(androidx.constraintlayout.core.widgets.ConstraintWidgetContainer,int)(https://developer.android.com/reference/androidx/constraintlayout/core/widgets/ConstraintWidgetContainer container, int state)` Update container of parameters for the state |

| ### Inherited Constants |
|---|
| From [androidx.constraintlayout.core.motion.utils.TypedValues](https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedValues) |---|---| | `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedValues#BOOLEAN_MASK() = 1` | | `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedValues#FLOAT_MASK() = 4` | | `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedValues#INT_MASK() = 2` | | `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedValues#STRING_MASK() = 8` | | `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedValues#S_CUSTOM() = "CUSTOM"` | | `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedValues#TYPE_FRAME_POSITION() = 100` | | `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedValues#TYPE_TARGET() = 101` | |

## Constants

### END

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

```
public static final int END = 1
```

### INTERPOLATED

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

```
public static final int INTERPOLATED = 2
```

### START

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

```
public static final int START = 0
```

## Public constructors

### Transition

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

```
public Transition(@NonNull CorePixelDp dpToPixel)
```

## Public methods

### addCustomColor

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

```
public void addCustomColor(int state, String widgetId, String property, int color)
```

### addCustomFloat

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

```
public void addCustomFloat(int state, String widgetId, String property, float value)
```

### addKeyAttribute

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

```
public void addKeyAttribute(String target, TypedBundle bundle)
```

### addKeyAttribute

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

```
public void addKeyAttribute(
    String target,
    TypedBundle bundle,
    CustomVariable[] custom
)
```

Add a key attribute and the custom variables into the

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html target` | the id of the target |
| `https://developer.android.com/reference/androidx/constraintlayout/core/motion/utils/TypedBundle bundle` | the key attributes bundle containing position etc. |
| `CustomVariable[] custom` | the customVariables to add at that position |

### addKeyCycle

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

```
public void addKeyCycle(String target, TypedBundle bundle)
```

### addKeyPosition

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

```
public void addKeyPosition(String target, TypedBundle bundle)
```

### addKeyPosition

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

```
public void addKeyPosition(String target, int frame, int type, float x, float y)
```

### calcStagger

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

```
public void calcStagger()
```

### clear

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

```
public void clear()
```

### contains

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

```
public boolean contains(String key)
```

### dragToProgress

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

```
public float dragToProgress(
    float currentProgress,
    int baseW,
    int baseH,
    float dx,
    float dy
)
```

Converts from xy drag to progress This should be used till touch up

| Parameters |
|---|---|
| `int baseW` | parent width |
| `int baseH` | parent height |
| `float dx` | change in x |
| `float dy` | change in y |

| Returns |
|---|---|
| `float` | the change in progress |

### fillKeyPositions

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

```
public void fillKeyPositions(WidgetFrame frame, float[] x, float[] y, float[] pos)
```

### findNextPosition

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

```
public Transition.KeyPosition findNextPosition(String target, int frameNumber)
```

### findPreviousPosition

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

```
public Transition.KeyPosition findPreviousPosition(String target, int frameNumber)
```

### getAutoTransition

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

```
public int getAutoTransition()
```

This gets the auto transition mode being used

### getEnd

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

```
public WidgetFrame getEnd(ConstraintWidget child)
```

Used in debug draw

### getEnd

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

```
public WidgetFrame getEnd(String id)
```

### getId

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

```
public int getId(String name)
```

### getInterpolated

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

```
public WidgetFrame getInterpolated(ConstraintWidget child)
```

Used after the interpolation

### getInterpolated

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

```
public WidgetFrame getInterpolated(String id)
```

### getInterpolatedHeight

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

```
public int getInterpolatedHeight()
```

### getInterpolatedWidth

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

```
public int getInterpolatedWidth()
```

### getInterpolator

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

```
public Interpolator getInterpolator()
```

This gets the interpolator being used

### getInterpolator

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

```
public static Interpolator getInterpolator(int interpolator, String interpolatorString)
```

get the interpolater based on a constant or a string

### getKeyFrames

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

```
public int getKeyFrames(
    String id,
    float[] rectangles,
    int[] pathMode,
    int[] position
)
```

### getMotion

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

```
public Motion getMotion(String id)
```

### getNumberKeyPositions

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

```
public int getNumberKeyPositions(WidgetFrame frame)
```

### getPath

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

```
public float[] getPath(String id)
```

### getStart

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

```
public WidgetFrame getStart(ConstraintWidget child)
```

Used in debug draw

### getStart

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

```
public WidgetFrame getStart(String id)
```

### getTouchUpProgress

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

```
public float getTouchUpProgress(long currentTime)
```

get the current touch up progress current time in nanoseconds (ideally coming from an animation clock)

| Parameters |
|---|---|
| `long currentTime` | in nanoseconds |

| Returns |
|---|---|
| `float` | progress |

### getWidgetState

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

```
public Transition.WidgetState getWidgetState(
    String widgetId,
    ConstraintWidget child,
    int transitionState
)
```

### hasOnSwipe

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

```
public boolean hasOnSwipe()
```

### hasPositionKeyframes

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

```
public boolean hasPositionKeyframes()
```

### interpolate

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

```
public void interpolate(int parentWidth, int parentHeight, float progress)
```

### isEmpty

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

```
public boolean isEmpty()
```

### isTouchNotDone

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

```
public boolean isTouchNotDone(float currentProgress)
```

Are we still animating

| Parameters |
|---|---|
| `float currentProgress` | motion progress |

| Returns |
|---|---|
| `boolean` | true to continue moving |

### setTouchUp

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

```
public void setTouchUp(
    float currentProgress,
    long currentTime,
    float velocityX,
    float velocityY
)
```

Set the start of the touch up

| Parameters |
|---|---|
| `float currentProgress` | 0...1 progress in |
| `long currentTime` | time in nanoseconds |
| `float velocityX` | pixels per millisecond |
| `float velocityY` | pixels per millisecond |

### setTransitionProperties

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

```
public void setTransitionProperties(TypedBundle bundle)
```

### setValue

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

```
public boolean setValue(int id, boolean value)
```

Used to set boolean values

| Returns |
|---|---|
| `boolean` | true if it accepted the value |

### setValue

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

```
public boolean setValue(int id, float value)
```

Used to set float values

| Returns |
|---|---|
| `boolean` | true if it accepted the value |

### setValue

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

```
public boolean setValue(int id, int value)
```

Used to set integer values

| Returns |
|---|---|
| `boolean` | true if it accepted the value |

### setValue

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

```
public boolean setValue(int id, String value)
```

Used to set String values

| Returns |
|---|---|
| `boolean` | true if it accepted the value |

### updateFrom

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

```
public void updateFrom(ConstraintWidgetContainer container, int state)
```

Update container of parameters for the state

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/core/widgets/ConstraintWidgetContainer container` | contains all the widget parameters |
| `int state` | starting or ending |