# Key

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/Key.java+class:androidx.constraintlayout.motion.widget.Key) Added in [2.2.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#2.2.2)

*** ** * ** ***


```
public abstract class Key
```

<br />

Known direct subclasses [KeyAttributes](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyAttributes), [KeyCycle](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyCycle), [KeyPosition](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition), [KeyTimeCycle](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTimeCycle), [KeyTrigger](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger)

|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyAttributes` | Defines container for a key frame of for storing KeyAttributes. |
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyCycle` | Provide the passive data structure to get KeyPosition information form XML |
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition` | Provide the passive data structure to get KeyPosition information form XML |
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTimeCycle` | Defines container for a key frame of for storing KeyTimeCycles. |
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger` | Defines container for a key frame of for storing KeyAttributes. |

*** ** * ** ***

Base class in an element in a KeyFrame

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#ALPHA() = "alpha"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#CURVEFIT() = "curveFit"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#CUSTOM() = "CUSTOM"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#ELEVATION() = "elevation"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#MOTIONPROGRESS() = "motionProgress"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#PIVOT_X() = "transformPivotX"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#PIVOT_Y() = "transformPivotY"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#PROGRESS() = "progress"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#ROTATION() = "rotation"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#ROTATION_X() = "rotationX"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#ROTATION_Y() = "rotationY"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#SCALE_X() = "scaleX"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#SCALE_Y() = "scaleY"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#TRANSITIONEASING() = "transitionEasing"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#TRANSITION_PATH_ROTATE() = "transitionPathRotate"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#TRANSLATION_X() = "translationX"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#TRANSLATION_Y() = "translationY"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#TRANSLATION_Z() = "translationZ"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#VISIBILITY() = "visibility"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#WAVE_OFFSET() = "waveOffset"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#WAVE_PERIOD() = "wavePeriod"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#WAVE_PHASE() = "wavePhase"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#WAVE_VARIES_BY() = "waveVariesBy"` |

| ### Public fields |
|---|---|
| `static int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#UNSET()` |

| ### Protected fields |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#mType()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#Key()()` |

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#addValues(java.util.HashMap<java.lang.String,androidx.constraintlayout.motion.utils.ViewSpline>)(https://developer.android.com/reference/java/util/HashMap.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/androidx/constraintlayout/motion/utils/ViewSpline> splines)` Defines method to add a a view to splines derived form this key frame. |
| `abstract https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#clone()()` Return a copy of this |
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#copy(androidx.constraintlayout.motion.widget.Key)(https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key src)` Return a copy of this key |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#getFramePosition()()` Gets the current frame position |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#setFramePosition(int)(int pos)` sets the frame position |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#setInterpolation(java.util.HashMap<java.lang.String,java.lang.Integer>)(https://developer.android.com/reference/java/util/HashMap.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Integer.html> interpolation)` Key frame can specify the type of interpolation it wants on various attributes For each string it set it to -1, CurveFit.LINEAR or CurveFit.SPLINE |
| `abstract void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#setValue(java.lang.String,java.lang.Object)(https://developer.android.com/reference/java/lang/String.html tag, https://developer.android.com/reference/java/lang/Object.html value)` Set the value associated with this tag |
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#setViewId(int)(int id)` set the id of the view |

## Constants

### ALPHA

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

```
public static final String ALPHA = "alpha"
```

### CURVEFIT

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

```
public static final String CURVEFIT = "curveFit"
```

### CUSTOM

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

```
public static final String CUSTOM = "CUSTOM"
```

### ELEVATION

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

```
public static final String ELEVATION = "elevation"
```

### MOTIONPROGRESS

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

```
public static final String MOTIONPROGRESS = "motionProgress"
```

### PIVOT_X

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

```
public static final String PIVOT_X = "transformPivotX"
```

### PIVOT_Y

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

```
public static final String PIVOT_Y = "transformPivotY"
```

### PROGRESS

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

```
public static final String PROGRESS = "progress"
```

### ROTATION

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

```
public static final String ROTATION = "rotation"
```

### ROTATION_X

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

```
public static final String ROTATION_X = "rotationX"
```

### ROTATION_Y

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

```
public static final String ROTATION_Y = "rotationY"
```

### SCALE_X

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

```
public static final String SCALE_X = "scaleX"
```

### SCALE_Y

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

```
public static final String SCALE_Y = "scaleY"
```

### TRANSITIONEASING

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

```
public static final String TRANSITIONEASING = "transitionEasing"
```

### TRANSITION_PATH_ROTATE

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

```
public static final String TRANSITION_PATH_ROTATE = "transitionPathRotate"
```

### TRANSLATION_X

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

```
public static final String TRANSLATION_X = "translationX"
```

### TRANSLATION_Y

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

```
public static final String TRANSLATION_Y = "translationY"
```

### TRANSLATION_Z

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

```
public static final String TRANSLATION_Z = "translationZ"
```

### VISIBILITY

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

```
public static final String VISIBILITY = "visibility"
```

### WAVE_OFFSET

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

```
public static final String WAVE_OFFSET = "waveOffset"
```

### WAVE_PERIOD

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

```
public static final String WAVE_PERIOD = "wavePeriod"
```

### WAVE_PHASE

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

```
public static final String WAVE_PHASE = "wavePhase"
```

### WAVE_VARIES_BY

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

```
public static final String WAVE_VARIES_BY = "waveVariesBy"
```

## Public fields

### UNSET

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

```
public static int UNSET
```

## Protected fields

### mType

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

```
protected int mType
```

## Public constructors

### Key

Added in 2.2.2

```
public Key()
```

## Public methods

### addValues

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

```
public abstract void addValues(HashMap<String, ViewSpline> splines)
```

Defines method to add a a view to splines derived form this key frame. The values are written to the spline

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/HashMap.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/androidx/constraintlayout/motion/utils/ViewSpline> splines` | splines to write values to |

### clone

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

```
public abstract Key clone()
```

Return a copy of this

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key` |   |

### copy

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

```
public Key copy(Key src)
```

Return a copy of this key

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key src` |   |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key` |   |

### getFramePosition

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

```
public int getFramePosition()
```

Gets the current frame position

| Returns |
|---|---|
| `int` |   |

### setFramePosition

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

```
public void setFramePosition(int pos)
```

sets the frame position

| Parameters |
|---|---|
| `int pos` |   |

### setInterpolation

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

```
public void setInterpolation(HashMap<String, Integer> interpolation)
```

Key frame can specify the type of interpolation it wants on various attributes For each string it set it to -1, CurveFit.LINEAR or CurveFit.SPLINE

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/HashMap.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Integer.html> interpolation` |   |

### setValue

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

```
public abstract void setValue(String tag, Object value)
```

Set the value associated with this tag

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html tag` |   |
| `https://developer.android.com/reference/java/lang/Object.html value` |   |

### setViewId

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

```
public Key setViewId(int id)
```

set the id of the view

| Parameters |
|---|---|
| `int id` |   |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key` |   |