# DesignTool

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

*** ** * ** ***


```
public class DesignTool
```

<br />

*** ** * ** ***

Utility class to manipulate MotionLayout from the layout editor

## Summary

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

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#designAccess(int,java.lang.String,java.lang.Object,float[],int,float[],int)( int cmd, https://developer.android.com/reference/java/lang/String.html type, https://developer.android.com/reference/java/lang/Object.html viewObject, float[] in, int inLength, float[] out, int outLength )` This is a general access to systems in the MotionLayout System This provides a series of commands used by the designer to access needed logic It is written this way to minimize the interface between the library and designer. |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#disableAutoTransition(boolean)(boolean disable)` this allow disabling autoTransitions to prevent design surface from being in undefined states |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#dumpConstraintSet(java.lang.String)(https://developer.android.com/reference/java/lang/String.html set)` |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getAnimationKeyFrames(java.lang.Object,float[])(https://developer.android.com/reference/java/lang/Object.html view, float[] key)` Get the location of the start end and key frames |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getAnimationPath(java.lang.Object,float[],int)(https://developer.android.com/reference/java/lang/Object.html view, float[] path, int len)` Get the center point of the animation path of a view |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getAnimationRectangles(java.lang.Object,float[])(https://developer.android.com/reference/java/lang/Object.html view, float[] path)` Get the center point of the animation path of a view |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getEndState()()` |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getKeyFrameInfo(java.lang.Object,int,int[])(https://developer.android.com/reference/java/lang/Object.html view, int type, int[] info)` Get the keyFrames for the view controlled by this MotionController. |
| `float` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getKeyFramePosition(java.lang.Object,int,float,float)(https://developer.android.com/reference/java/lang/Object.html view, int type, float x, float y)` |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getKeyFramePositions(java.lang.Object,int[],float[])(https://developer.android.com/reference/java/lang/Object.html view, int[] type, float[] pos)` Get the keyFrames for the view controlled by this MotionController. |
| `https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getKeyframe(int,int,int)(int type, int target, int position)` |
| `https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getKeyframe(java.lang.Object,int,int)(https://developer.android.com/reference/java/lang/Object.html view, int type, int position)` |
| `https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getKeyframeAtLocation(java.lang.Object,float,float)(https://developer.android.com/reference/java/lang/Object.html viewObject, float x, float y)` |
| `https://developer.android.com/reference/java/lang/Boolean.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getPositionKeyframe(java.lang.Object,java.lang.Object,float,float,java.lang.String[],float[])( https://developer.android.com/reference/java/lang/Object.html keyFrame, https://developer.android.com/reference/java/lang/Object.html view, float x, float y, String[] attribute, float[] value )` |
| `float` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getProgress()()` Return the current progress of the current transition |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getStartState()()` |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getState()()` Return the current state (ConstraintSet id) as a string |
| `long` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#getTransitionTimeMs()()` Gets the time of the currently set animation. |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#isInTransition()()` Utility method, returns true if we are currently in a transition |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#setAttributes(int,java.lang.String,java.lang.Object,java.lang.Object)( int dpi, https://developer.android.com/reference/java/lang/String.html constraintSetId, https://developer.android.com/reference/java/lang/Object.html opaqueView, https://developer.android.com/reference/java/lang/Object.html opaqueAttributes )` Live setting of attributes on a view |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#setKeyFrame(java.lang.Object,int,java.lang.String,java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html view, int position, https://developer.android.com/reference/java/lang/String.html name, https://developer.android.com/reference/java/lang/Object.html value)` |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#setKeyFramePosition(java.lang.Object,int,int,float,float)(https://developer.android.com/reference/java/lang/Object.html view, int position, int type, float x, float y)` Move the widget directly |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#setKeyframe(java.lang.Object,java.lang.String,java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html keyFrame, https://developer.android.com/reference/java/lang/String.html tag, https://developer.android.com/reference/java/lang/Object.html value)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#setState(java.lang.String)(https://developer.android.com/reference/java/lang/String.html id)` This sets the constraint set based on a string. |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#setToolPosition(float)(float position)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#setTransition(java.lang.String,java.lang.String)(https://developer.android.com/reference/java/lang/String.html start, https://developer.android.com/reference/java/lang/String.html end)` This sets the constraint set based on a string. |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/motion/widget/DesignTool#setViewDebug(java.lang.Object,int)(https://developer.android.com/reference/java/lang/Object.html view, int debugMode)` |

## Public constructors

### DesignTool

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

```
public DesignTool(MotionLayout motionLayout)
```

## Public methods

### designAccess

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

```
public int designAccess(
    int cmd,
    String type,
    Object viewObject,
    float[] in,
    int inLength,
    float[] out,
    int outLength
)
```

This is a general access to systems in the MotionLayout System This provides a series of commands used by the designer to access needed logic It is written this way to minimize the interface between the library and designer. It allows the logic to be kept only in the library not replicated in the gui builder. It also allows us to understand understand the version of MotionLayout in use commands 0 return the version number 1 Get the center point of the animation path of a view 2 Get the location of the start end and key frames

| Parameters |
|---|---|
| `int cmd` | this provide the command needed |
| `https://developer.android.com/reference/java/lang/String.html type` | support argument for command |
| `https://developer.android.com/reference/java/lang/Object.html viewObject` | if this command references a view this provides access |
| `float[] in` | this allows for an array of float to be the input to the system |
| `int inLength` | this provides the length of the input |
| `float[] out` | this provide the output array |
| `int outLength` | the length of the output array |

| Returns |
|---|---|
| `int` | command dependent -1 is typically an error (do not understand) |

### disableAutoTransition

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

```
public void disableAutoTransition(boolean disable)
```

this allow disabling autoTransitions to prevent design surface from being in undefined states

| Parameters |
|---|---|
| `boolean disable` |   |

### dumpConstraintSet

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

```
public void dumpConstraintSet(String set)
```

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

### getAnimationKeyFrames

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

```
public int getAnimationKeyFrames(Object view, float[] key)
```

Get the location of the start end and key frames

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html view` | the view to track |
| `float[] key` | array to be filled |

| Returns |
|---|---|
| `int` | number of key frames + 2 |

### getAnimationPath

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

```
public int getAnimationPath(Object view, float[] path, int len)
```

Get the center point of the animation path of a view

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html view` | view to getMap the animation of |
| `float[] path` | array to be filled (x1,y1,x2,y2...) |

| Returns |
|---|---|
| `int` | -1 if not under and animation 0 if not animated or number of point along animation |

### getAnimationRectangles

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

```
public void getAnimationRectangles(Object view, float[] path)
```

Get the center point of the animation path of a view

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html view` | view to getMap the animation of |
| `float[] path` | array to be filled (in groups of 8) (x1,y1,x2,y2...) |

### getEndState

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

```
public String getEndState()
```

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` |   |

### getKeyFrameInfo

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

```
public int getKeyFrameInfo(Object view, int type, int[] info)
```

Get the keyFrames for the view controlled by this MotionController. The call is designed to be efficient because it will be called 30x Number of views a second

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html view` | the view to return keyframe positions |
| `int[] info` |   |

| Returns |
|---|---|
| `int` | Number of keyFrames found |

### getKeyFramePosition

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

```
public float getKeyFramePosition(Object view, int type, float x, float y)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html view` |   |
| `int type` |   |
| `float x` |   |
| `float y` |   |

| Returns |
|---|---|
| `float` |   |

### getKeyFramePositions

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

```
public int getKeyFramePositions(Object view, int[] type, float[] pos)
```

Get the keyFrames for the view controlled by this MotionController. The call is designed to be efficient because it will be called 30x Number of views a second

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html view` | the view to return keyframe positions |
| `int[] type` | is pos(0-100) + 1000\*mType(1=Attrib, 2=Position, 3=TimeCycle 4=Cycle 5=Trigger |
| `float[] pos` | the x\&y position of the keyFrame along the path |

| Returns |
|---|---|
| `int` | Number of keyFrames found |

### getKeyframe

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

```
public Object getKeyframe(int type, int target, int position)
```

| Parameters |
|---|---|
| `int type` |   |
| `int target` |   |
| `int position` |   |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html` |   |

### getKeyframe

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

```
public Object getKeyframe(Object view, int type, int position)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html view` |   |
| `int type` |   |
| `int position` |   |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html` |   |

### getKeyframeAtLocation

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

```
public Object getKeyframeAtLocation(Object viewObject, float x, float y)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html viewObject` |   |
| `float x` |   |
| `float y` |   |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html` |   |

### getPositionKeyframe

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

```
public Boolean getPositionKeyframe(
    Object keyFrame,
    Object view,
    float x,
    float y,
    String[] attribute,
    float[] value
)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html keyFrame` |   |
| `https://developer.android.com/reference/java/lang/Object.html view` |   |
| `float x` |   |
| `float y` |   |
| `String[] attribute` |   |
| `float[] value` |   |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/Boolean.html` |   |

### getProgress

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

```
public float getProgress()
```

Return the current progress of the current transition

| Returns |
|---|---|
| `float` | current transition's progress |

### getStartState

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

```
public String getStartState()
```

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` |   |

### getState

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

```
public String getState()
```

Return the current state (ConstraintSet id) as a string

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | the last state set via the design tool bridge |

### getTransitionTimeMs

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

```
public long getTransitionTimeMs()
```

Gets the time of the currently set animation.

| Returns |
|---|---|
| `long` | time in Milliseconds |

### isInTransition

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

```
public boolean isInTransition()
```

Utility method, returns true if we are currently in a transition

| Returns |
|---|---|
| `boolean` | true if in a transition, false otherwise |

### setAttributes

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

```
public void setAttributes(
    int dpi,
    String constraintSetId,
    Object opaqueView,
    Object opaqueAttributes
)
```

Live setting of attributes on a view

| Parameters |
|---|---|
| `int dpi` | dpi used by the application |
| `https://developer.android.com/reference/java/lang/String.html constraintSetId` | ConstraintSet id |
| `https://developer.android.com/reference/java/lang/Object.html opaqueView` | the Android View we operate on, passed as an Object |
| `https://developer.android.com/reference/java/lang/Object.html opaqueAttributes` | the list of attributes (hash) we pass to the view |

### setKeyFrame

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

```
public void setKeyFrame(Object view, int position, String name, Object value)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html view` |   |
| `int position` |   |
| `https://developer.android.com/reference/java/lang/String.html name` |   |
| `https://developer.android.com/reference/java/lang/Object.html value` |   |

### setKeyFramePosition

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

```
public boolean setKeyFramePosition(Object view, int position, int type, float x, float y)
```

Move the widget directly

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html view` |   |
| `int position` |   |
| `int type` |   |
| `float x` |   |
| `float y` |   |

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

### setKeyframe

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

```
public void setKeyframe(Object keyFrame, String tag, Object value)
```

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

### setState

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

```
public void setState(String id)
```

This sets the constraint set based on a string. (without the "@+id/")

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

### setToolPosition

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

```
public void setToolPosition(float position)
```

| Parameters |
|---|---|
| `float position` |   |

### setTransition

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

```
public void setTransition(String start, String end)
```

This sets the constraint set based on a string. (without the "@+id/")

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html start` |   |
| `https://developer.android.com/reference/java/lang/String.html end` |   |

### setViewDebug

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

```
public void setViewDebug(Object view, int debugMode)
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html view` |   |
| `int debugMode` |   |