# MotionKey

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

*** ** * ** ***


```
abstract class MotionKey : TypedValues
```

<br />

Known direct subclasses [MotionKeyAttributes](https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKeyAttributes), [MotionKeyCycle](https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKeyCycle), [MotionKeyPosition](https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKeyPosition), [MotionKeyTimeCycle](https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKeyTimeCycle), [MotionKeyTrigger](https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKeyTrigger)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKeyAttributes` |   |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKeyCycle` |   |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKeyPosition` |   |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKeyTimeCycle` |   |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKeyTrigger` |   |

*** ** * ** ***

Base class in an element in a KeyFrame

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#ALPHA() = "alpha"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#CUSTOM() = "CUSTOM"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#ELEVATION() = "elevation"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#ROTATION() = "rotationZ"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#ROTATION_X() = "rotationX"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#SCALE_X() = "scaleX"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#SCALE_Y() = "scaleY"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#TRANSITION_PATH_ROTATE() = "transitionPathRotate"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#TRANSLATION_X() = "translationX"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#TRANSLATION_Y() = "translationY"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#VISIBILITY() = "visibility"` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#MotionKey()()` |

| ### Public functions |
|---|---|
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#addValues(java.util.HashMap<java.lang.String,androidx.constraintlayout.core.motion.utils.SplineSet>)(splines: https://developer.android.com/reference/java/util/HashMap.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/SplineSet!>!)` Defines method to add a a view to splines derived form this key frame. |
| `abstract https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#clone()()` |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#copy(androidx.constraintlayout.core.motion.key.MotionKey)(src: https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey!)` |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#getAttributeNames(java.util.HashSet<java.lang.String>)(attributes: https://developer.android.com/reference/java/util/HashSet.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#getFramePosition()()` Gets the current frame position |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#setCustomAttribute(java.lang.String,int,boolean)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#setCustomAttribute(java.lang.String,int,float)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#setCustomAttribute(java.lang.String,int,int)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#setCustomAttribute(java.lang.String,int,java.lang.String)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#setFramePosition(int)(pos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` sets the frame position |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#setInterpolation(java.util.HashMap<java.lang.String,java.lang.Integer>)(interpolation: https://developer.android.com/reference/java/util/HashMap.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>!)` 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 |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#setValue(int,boolean)(type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Used to set boolean values |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#setValue(int,float)(type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Used to set float values |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#setValue(int,int)(type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Used to set integer values |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#setValue(int,java.lang.String)(type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Used to set String values |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#setViewId(int)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

| ### Public properties |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#UNSET()` |
| `https://developer.android.com/reference/java/util/HashMap.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/CustomVariable!>!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#mCustom()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#mFramePosition()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/key/MotionKey#mType()` |

| ### Inherited Constants |
|---|
| From [androidx.constraintlayout.core.motion.utils.TypedValues](https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/TypedValues) |---|---| | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/TypedValues#BOOLEAN_MASK() = 1` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/TypedValues#FLOAT_MASK() = 4` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/TypedValues#INT_MASK() = 2` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/TypedValues#STRING_MASK() = 8` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/TypedValues#S_CUSTOM() = "CUSTOM"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/TypedValues#TYPE_FRAME_POSITION() = 100` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/TypedValues#TYPE_TARGET() = 101` | |

| ### Inherited functions |
|---|
| From [androidx.constraintlayout.core.motion.utils.TypedValues](https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/TypedValues) |---|---| | `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/TypedValues#getId(java.lang.String)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` | |

## Constants

### ALPHA

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

```
const val ALPHA = "alpha": String!
```

### CUSTOM

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

```
const val CUSTOM = "CUSTOM": String!
```

### ELEVATION

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

```
const val ELEVATION = "elevation": String!
```

### ROTATION

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

```
const val ROTATION = "rotationZ": String!
```

### ROTATION_X

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

```
const val ROTATION_X = "rotationX": String!
```

### SCALE_X

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

```
const val SCALE_X = "scaleX": String!
```

### SCALE_Y

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

```
const val SCALE_Y = "scaleY": String!
```

### TRANSITION_PATH_ROTATE

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

```
const val TRANSITION_PATH_ROTATE = "transitionPathRotate": String!
```

### TRANSLATION_X

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

```
const val TRANSLATION_X = "translationX": String!
```

### TRANSLATION_Y

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

```
const val TRANSLATION_Y = "translationY": String!
```

### VISIBILITY

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

```
const val VISIBILITY = "visibility": String!
```

## Public constructors

### MotionKey

Added in 1.1.2

```
MotionKey()
```

## Public functions

### addValues

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

```
abstract fun addValues(splines: HashMap<String!, SplineSet!>!): Unit
```

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

| Parameters |
|---|---|
| `splines: https://developer.android.com/reference/java/util/HashMap.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://developer.android.com/reference/kotlin/androidx/constraintlayout/core/motion/utils/SplineSet!>!` | splines to write values to |

### clone

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

```
abstract fun clone(): MotionKey!
```

### copy

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

```
fun copy(src: MotionKey!): MotionKey!
```

### getAttributeNames

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

```
abstract fun getAttributeNames(attributes: HashSet<String!>!): Unit
```

### getFramePosition

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

```
fun getFramePosition(): Int
```

Gets the current frame position

### setCustomAttribute

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

```
fun setCustomAttribute(name: String!, type: Int, value: Boolean): Unit
```

### setCustomAttribute

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

```
fun setCustomAttribute(name: String!, type: Int, value: Float): Unit
```

### setCustomAttribute

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

```
fun setCustomAttribute(name: String!, type: Int, value: Int): Unit
```

### setCustomAttribute

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

```
fun setCustomAttribute(name: String!, type: Int, value: String!): Unit
```

### setFramePosition

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

```
fun setFramePosition(pos: Int): Unit
```

sets the frame position

### setInterpolation

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

```
fun setInterpolation(interpolation: HashMap<String!, Int!>!): Unit
```

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

### setValue

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

```
fun setValue(type: Int, value: Boolean): Boolean
```

Used to set boolean values

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true if it accepted the value |

### setValue

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

```
fun setValue(type: Int, value: Float): Boolean
```

Used to set float values

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true if it accepted the value |

### setValue

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

```
fun setValue(type: Int, value: Int): Boolean
```

Used to set integer values

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true if it accepted the value |

### setValue

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

```
fun setValue(type: Int, value: String!): Boolean
```

Used to set String values

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true if it accepted the value |

### setViewId

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

```
fun setViewId(id: Int): MotionKey!
```

## Public properties

### UNSET

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

```
java-static val UNSET: Int
```

### mCustom

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

```
val mCustom: HashMap<String!, CustomVariable!>!
```

### mFramePosition

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

```
val mFramePosition: Int
```

### mType

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

```
val mType: Int
```