# 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)

*** ** * ** ***


```
public class KeyTrigger extends Key
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.constraintlayout.motion.widget.Key](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key) ||
|   | ↳ | [androidx.constraintlayout.motion.widget.KeyTrigger](https://developer.android.com/reference/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 |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#CROSS() = "CROSS"` |
| `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#KEY_TYPE() = 5` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#NEGATIVE_CROSS() = "negativeCross"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#POSITIVE_CROSS() = "positiveCross"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#POST_LAYOUT() = "postLayout"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#TRIGGER_COLLISION_ID() = "triggerCollisionId"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#TRIGGER_COLLISION_VIEW() = "triggerCollisionView"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#TRIGGER_ID() = "triggerID"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#TRIGGER_RECEIVER() = "triggerReceiver"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#TRIGGER_SLACK() = "triggerSlack"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#VIEW_TRANSITION_ON_CROSS() = "viewTransitionOnCross"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#VIEW_TRANSITION_ON_NEGATIVE_CROSS() = "viewTransitionOnNegativeCross"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#VIEW_TRANSITION_ON_POSITIVE_CROSS() = "viewTransitionOnPositiveCross"` |

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

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#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. |
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#clone()()` Clone this KeyAttributes |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#conditionallyFire(float,android.view.View)(float pos, https://developer.android.com/reference/android/view/View.html child)` This fires the keyTriggers associated with this view at that position |
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#copy(androidx.constraintlayout.motion.widget.Key)(https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key src)` Copy the key |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#getAttributeNames(java.util.HashSet<java.lang.String>)(https://developer.android.com/reference/java/util/HashSet.html<https://developer.android.com/reference/java/lang/String.html> attributes)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#load(android.content.Context,android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyTrigger#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 |

| ### Inherited Constants |
|---|
| From [androidx.constraintlayout.motion.widget.Key](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key) |---|---| | `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"` | |

| ### Inherited fields |
|---|
| From [androidx.constraintlayout.motion.widget.Key](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key) |---|---| | `static int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#UNSET()` | | `int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key#mType()` | |

| ### Inherited methods |
|---|
| From [androidx.constraintlayout.motion.widget.Key](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/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 | | `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

### CROSS

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

```
public static final String CROSS = "CROSS"
```

### KEY_TYPE

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

```
public static final int KEY_TYPE = 5
```

### NEGATIVE_CROSS

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

```
public static final String NEGATIVE_CROSS = "negativeCross"
```

### POSITIVE_CROSS

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

```
public static final String POSITIVE_CROSS = "positiveCross"
```

### POST_LAYOUT

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

```
public static final String POST_LAYOUT = "postLayout"
```

### TRIGGER_COLLISION_ID

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

```
public static final String TRIGGER_COLLISION_ID = "triggerCollisionId"
```

### TRIGGER_COLLISION_VIEW

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

```
public static final String TRIGGER_COLLISION_VIEW = "triggerCollisionView"
```

### TRIGGER_ID

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

```
public static final String TRIGGER_ID = "triggerID"
```

### TRIGGER_RECEIVER

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

```
public static final String TRIGGER_RECEIVER = "triggerReceiver"
```

### TRIGGER_SLACK

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

```
public static final String TRIGGER_SLACK = "triggerSlack"
```

### VIEW_TRANSITION_ON_CROSS

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

```
public static final String VIEW_TRANSITION_ON_CROSS = "viewTransitionOnCross"
```

### VIEW_TRANSITION_ON_NEGATIVE_CROSS

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

```
public static final String VIEW_TRANSITION_ON_NEGATIVE_CROSS = "viewTransitionOnNegativeCross"
```

### VIEW_TRANSITION_ON_POSITIVE_CROSS

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

```
public static final String VIEW_TRANSITION_ON_POSITIVE_CROSS = "viewTransitionOnPositiveCross"
```

## Public constructors

### KeyTrigger

Added in 2.2.2

```
public KeyTrigger()
```

## Public methods

### addValues

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

```
public 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 Key clone()
```

Clone this KeyAttributes

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

### conditionallyFire

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

```
public void conditionallyFire(float pos, View child)
```

This fires the keyTriggers associated with this view at that position

| Parameters |
|---|---|
| `float pos` | the progress |
| `https://developer.android.com/reference/android/view/View.html child` | the view |

### copy

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

Copy the key

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

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

### getAttributeNames

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

```
public void getAttributeNames(HashSet<String> attributes)
```

### load

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

```
public void load(Context context, AttributeSet attrs)
```

### setValue

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

```
public 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` |   |