# KeyPosition

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

*** ** * ** ***


```
public class KeyPosition 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.KeyPosition](https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition) |

*** ** * ** ***

Provide the passive data structure to get KeyPosition information form XML

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#DRAWPATH() = "drawPath"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#PERCENT_HEIGHT() = "percentHeight"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#PERCENT_WIDTH() = "percentWidth"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#PERCENT_X() = "percentX"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#PERCENT_Y() = "percentY"` |
| `static final float` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#SELECTION_SLOPE() = 20.0f` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#SIZE_PERCENT() = "sizePercent"` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#TRANSITION_EASING() = "transitionEasing"` |
| `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#TYPE_AXIS() = 3` |
| `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#TYPE_CARTESIAN() = 0` |
| `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#TYPE_PATH() = 1` |
| `static final int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#TYPE_SCREEN() = 2` |

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

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#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/KeyPosition#clone()()` Clone this KeyAttributes |
| `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#copy(androidx.constraintlayout.motion.widget.Key)(https://developer.android.com/reference/androidx/constraintlayout/motion/widget/Key src)` Copy the key |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#intersects(int,int,android.graphics.RectF,android.graphics.RectF,float,float)( int layoutWidth, int layoutHeight, https://developer.android.com/reference/android/graphics/RectF.html start, https://developer.android.com/reference/android/graphics/RectF.html end, float x, float y )` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#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/KeyPosition#positionAttributes(android.view.View,android.graphics.RectF,android.graphics.RectF,float,float,java.lang.String[],float[])( https://developer.android.com/reference/android/view/View.html view, https://developer.android.com/reference/android/graphics/RectF.html start, https://developer.android.com/reference/android/graphics/RectF.html end, float x, float y, String[] attribute, float[] value )` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#setType(int)(int type)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/KeyPosition#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

### DRAWPATH

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

```
public static final String DRAWPATH = "drawPath"
```

### PERCENT_HEIGHT

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

```
public static final String PERCENT_HEIGHT = "percentHeight"
```

### PERCENT_WIDTH

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

```
public static final String PERCENT_WIDTH = "percentWidth"
```

### PERCENT_X

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

```
public static final String PERCENT_X = "percentX"
```

### PERCENT_Y

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

```
public static final String PERCENT_Y = "percentY"
```

### SELECTION_SLOPE

```
protected static final float SELECTION_SLOPE = 20.0f
```

### SIZE_PERCENT

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

```
public static final String SIZE_PERCENT = "sizePercent"
```

### TRANSITION_EASING

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

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

### TYPE_AXIS

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

```
public static final int TYPE_AXIS = 3
```

### TYPE_CARTESIAN

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

```
public static final int TYPE_CARTESIAN = 0
```

### TYPE_PATH

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

```
public static final int TYPE_PATH = 1
```

### TYPE_SCREEN

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

```
public static final int TYPE_SCREEN = 2
```

## Public constructors

### KeyPosition

Added in 2.2.2

```
public KeyPosition()
```

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

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

### intersects

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

```
public boolean intersects(
    int layoutWidth,
    int layoutHeight,
    RectF start,
    RectF end,
    float x,
    float y
)
```

| Parameters |
|---|---|
| `int layoutWidth` |   |
| `int layoutHeight` |   |
| `https://developer.android.com/reference/android/graphics/RectF.html start` |   |
| `https://developer.android.com/reference/android/graphics/RectF.html end` |   |
| `float x` |   |
| `float y` |   |

| Returns |
|---|---|
| `boolean` |   |

### load

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

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

### positionAttributes

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

```
public void positionAttributes(
    View view,
    RectF start,
    RectF end,
    float x,
    float y,
    String[] attribute,
    float[] value
)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/view/View.html view` |   |
| `https://developer.android.com/reference/android/graphics/RectF.html start` |   |
| `https://developer.android.com/reference/android/graphics/RectF.html end` |   |
| `float x` |   |
| `float y` |   |
| `String[] attribute` |   |
| `float[] value` |   |

### setType

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

```
public void setType(int type)
```

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