# KeyTrigger

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

*** ** * ** ***


```
class KeyTrigger : Key
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.constraintlayout.motion.widget.Key](https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key) ||
|   | ↳ | [androidx.constraintlayout.motion.widget.KeyTrigger](https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger) |

*** ** * ** ***

Defines container for a key frame of for storing KeyAttributes. KeyAttributes change post layout values of a view.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#CROSS() = "CROSS"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#KEY_TYPE() = 5` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#NEGATIVE_CROSS() = "negativeCross"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#POSITIVE_CROSS() = "positiveCross"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#POST_LAYOUT() = "postLayout"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#TRIGGER_COLLISION_ID() = "triggerCollisionId"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#TRIGGER_COLLISION_VIEW() = "triggerCollisionView"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#TRIGGER_ID() = "triggerID"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#TRIGGER_RECEIVER() = "triggerReceiver"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#TRIGGER_SLACK() = "triggerSlack"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#VIEW_TRANSITION_ON_CROSS() = "viewTransitionOnCross"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#VIEW_TRANSITION_ON_NEGATIVE_CROSS() = "viewTransitionOnNegativeCross"` |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#VIEW_TRANSITION_ON_POSITIVE_CROSS() = "viewTransitionOnPositiveCross"` |

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

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#addValues(java.util.HashMap<java.lang.String,androidx.constraintlayout.motion.utils.ViewSpline>)(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/motion/utils/ViewSpline!>!)` Defines method to add a a view to splines derived form this key frame. |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#clone()()` Clone this KeyAttributes |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#conditionallyFire(float,android.view.View)(pos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, child: https://developer.android.com/reference/android/view/View.html!)` This fires the keyTriggers associated with this view at that position |
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#copy(androidx.constraintlayout.motion.widget.Key)(src: https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key!)` Copy the key |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#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/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#load(android.content.Context,android.util.AttributeSet)(context: https://developer.android.com/reference/android/content/Context.html!, attrs: https://developer.android.com/reference/android/util/AttributeSet.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/KeyTrigger#setValue(java.lang.String,java.lang.Object)(tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)` Set the value associated with this tag |

| ### Inherited Constants |
|---|
| From [androidx.constraintlayout.motion.widget.Key](https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key) |---|---| | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#ALPHA() = "alpha"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#CURVEFIT() = "curveFit"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#CUSTOM() = "CUSTOM"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#ELEVATION() = "elevation"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#MOTIONPROGRESS() = "motionProgress"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#PIVOT_X() = "transformPivotX"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#PIVOT_Y() = "transformPivotY"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#PROGRESS() = "progress"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#ROTATION() = "rotation"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#ROTATION_X() = "rotationX"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#ROTATION_Y() = "rotationY"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#SCALE_X() = "scaleX"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#SCALE_Y() = "scaleY"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#TRANSITIONEASING() = "transitionEasing"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#TRANSITION_PATH_ROTATE() = "transitionPathRotate"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#TRANSLATION_X() = "translationX"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#TRANSLATION_Y() = "translationY"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#TRANSLATION_Z() = "translationZ"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#VISIBILITY() = "visibility"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#WAVE_OFFSET() = "waveOffset"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#WAVE_PERIOD() = "wavePeriod"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#WAVE_PHASE() = "wavePhase"` | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#WAVE_VARIES_BY() = "waveVariesBy"` | |

| ### Inherited functions |
|---|
| From [androidx.constraintlayout.motion.widget.Key](https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key) |---|---| | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#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/motion/widget/Key#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/motion/widget/Key#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://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#setViewId(int)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` set the id of the view | |

| ### Inherited properties |
|---|
| From [androidx.constraintlayout.motion.widget.Key](https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key) |---|---| | `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#UNSET()` | | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key#mType()` | |

## Constants

### CROSS

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

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

### KEY_TYPE

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

```
const val KEY_TYPE = 5: Int
```

### NEGATIVE_CROSS

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

```
const val NEGATIVE_CROSS = "negativeCross": String!
```

### POSITIVE_CROSS

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

```
const val POSITIVE_CROSS = "positiveCross": String!
```

### POST_LAYOUT

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

```
const val POST_LAYOUT = "postLayout": String!
```

### TRIGGER_COLLISION_ID

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

```
const val TRIGGER_COLLISION_ID = "triggerCollisionId": String!
```

### TRIGGER_COLLISION_VIEW

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

```
const val TRIGGER_COLLISION_VIEW = "triggerCollisionView": String!
```

### TRIGGER_ID

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

```
const val TRIGGER_ID = "triggerID": String!
```

### TRIGGER_RECEIVER

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

```
const val TRIGGER_RECEIVER = "triggerReceiver": String!
```

### TRIGGER_SLACK

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

```
const val TRIGGER_SLACK = "triggerSlack": String!
```

### VIEW_TRANSITION_ON_CROSS

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

```
const val VIEW_TRANSITION_ON_CROSS = "viewTransitionOnCross": String!
```

### VIEW_TRANSITION_ON_NEGATIVE_CROSS

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

```
const val VIEW_TRANSITION_ON_NEGATIVE_CROSS = "viewTransitionOnNegativeCross": String!
```

### VIEW_TRANSITION_ON_POSITIVE_CROSS

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

```
const val VIEW_TRANSITION_ON_POSITIVE_CROSS = "viewTransitionOnPositiveCross": String!
```

## Public constructors

### KeyTrigger

Added in 2.2.2

```
KeyTrigger()
```

## Public functions

### addValues

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

```
fun addValues(splines: HashMap<String!, ViewSpline!>!): 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/motion/utils/ViewSpline!>!` | splines to write values to |

### clone

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

```
fun clone(): Key!
```

Clone this KeyAttributes

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

### conditionallyFire

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

```
fun conditionallyFire(pos: Float, child: View!): Unit
```

This fires the keyTriggers associated with this view at that position

| Parameters |
|---|---|
| `pos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the progress |
| `child: https://developer.android.com/reference/android/view/View.html!` | the view |

### copy

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

Copy the key

| Parameters |
|---|---|
| `src: https://developer.android.com/reference/kotlin/androidx/constraintlayout/motion/widget/Key!` | to be copied |

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

### getAttributeNames

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

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

### load

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

```
fun load(context: Context!, attrs: AttributeSet!): Unit
```

### setValue

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

```
fun setValue(tag: String!, value: Any!): Unit
```

Set the value associated with this tag

| Parameters |
|---|---|
| `tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` |   |
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` |   |