# State

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

*** ** * ** ***


```
public class State
```

<br />

*** ** * ** ***

Represents a full state of a ConstraintLayout

## Summary

| ### Nested types |
|---|
| `public enum https://developer.android.com/reference/androidx/constraintlayout/core/state/State.Chain` |
| `public enum https://developer.android.com/reference/androidx/constraintlayout/core/state/State.Constraint` |
| `public enum https://developer.android.com/reference/androidx/constraintlayout/core/state/State.Direction` |
| `public enum https://developer.android.com/reference/androidx/constraintlayout/core/state/State.Helper` |
| `public enum https://developer.android.com/reference/androidx/constraintlayout/core/state/State.Wrap` |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/Integer.html` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#PARENT()` |

| ### Public fields |
|---|---|
| `final https://developer.android.com/reference/androidx/constraintlayout/core/state/ConstraintReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#mParent()` |

| ### Protected fields |
|---|---|
| `https://developer.android.com/reference/java/util/HashMap.html<https://developer.android.com/reference/java/lang/Object.html, https://developer.android.com/reference/androidx/constraintlayout/core/state/HelperReference>` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#mHelperReferences()` |
| `https://developer.android.com/reference/java/util/HashMap.html<https://developer.android.com/reference/java/lang/Object.html, https://developer.android.com/reference/androidx/constraintlayout/core/state/Reference>` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#mReferences()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#State()()` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#apply(androidx.constraintlayout.core.widgets.ConstraintWidgetContainer)(https://developer.android.com/reference/androidx/constraintlayout/core/widgets/ConstraintWidgetContainer container)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/BarrierReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#barrier(java.lang.Object,androidx.constraintlayout.core.state.State.Direction)(https://developer.android.com/reference/java/lang/Object.html key, https://developer.android.com/reference/androidx/constraintlayout/core/state/State.Direction direction)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#baselineNeededFor(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html id)` Baseline is needed for this object |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/AlignHorizontallyReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#centerHorizontally(java.lang.Object...)(Object[] references)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/AlignVerticallyReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#centerVertically(java.lang.Object...)(Object[] references)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/ConstraintReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#constraints(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html key)` |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#convertDimension(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html value)` Implements a conversion function for values, returning int. |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/ConstraintReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#createConstraintReference(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html key)` Create a new reference given a key. |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#directMapping()()` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/FlowReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#getFlow(java.lang.Object,boolean)(https://developer.android.com/reference/java/lang/Object.html key, boolean vertical)` Gets a reference to a Flow object. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/GridReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#getGrid(java.lang.Object,java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html key, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html gridType)` Get a Grid reference |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/FlowReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#getHorizontalFlow()()` Get a HorizontalFlowReference |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/FlowReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#getHorizontalFlow(java.lang.Object...)(Object[] references)` Get a HorizontalFlowReference and add it to references |
| `https://developer.android.com/reference/java/util/ArrayList.html<https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#getIdsForTag(java.lang.String)(https://developer.android.com/reference/java/lang/String.html tag)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/FlowReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#getVerticalFlow()()` Get a VerticalFlowReference |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/FlowReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#getVerticalFlow(java.lang.Object...)(Object[] references)` Get a VerticalFlowReference and add it to references |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/GuidelineReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#guideline(java.lang.Object,int)(https://developer.android.com/reference/java/lang/Object.html key, int orientation)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/State` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#height(androidx.constraintlayout.core.state.Dimension)(https://developer.android.com/reference/androidx/constraintlayout/core/state/Dimension dimension)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/HelperReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#helper(java.lang.Object,androidx.constraintlayout.core.state.State.Helper)(https://developer.android.com/reference/java/lang/Object.html key, https://developer.android.com/reference/androidx/constraintlayout/core/state/State.Helper type)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/HorizontalChainReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#horizontalChain()()` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/HorizontalChainReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#horizontalChain(java.lang.Object...)(Object[] references)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/GuidelineReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#horizontalGuideline(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html key)` |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#isBaselineNeeded(androidx.constraintlayout.core.widgets.ConstraintWidget)(https://developer.android.com/reference/androidx/constraintlayout/core/widgets/ConstraintWidget constraintWidget)` Does this constraintWidget need a baseline |
| `boolean` | `[isLtr](https://developer.android.com/reference/androidx/constraintlayout/core/state/State#isLtr())()` **This method is deprecated.** For consistency, use `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#isRtl()` instead. <br /> |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#isRtl()()` Returns true if layout direction is right to left. |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#map(java.lang.Object,java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html key, https://developer.android.com/reference/java/lang/Object.html view)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#reset()()` Clear the state |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#sameFixedHeight(int)(int height)` |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#sameFixedWidth(int)(int width)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#setDpToPixel(androidx.constraintlayout.core.state.CorePixelDp)(https://developer.android.com/reference/androidx/constraintlayout/core/state/CorePixelDp dpToPixel)` Set the function that converts dp to Pixels |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/State` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#setHeight(androidx.constraintlayout.core.state.Dimension)(https://developer.android.com/reference/androidx/constraintlayout/core/state/Dimension dimension)` |
| `void` | `[setLtr](https://developer.android.com/reference/androidx/constraintlayout/core/state/State#setLtr(boolean))(boolean isLtr)` **This method is deprecated.** For consistency, use `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#setRtl(boolean)` instead. <br /> |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#setRtl(boolean)(boolean isRtl)` Set whether the layout direction is right to left (Rtl). |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#setTag(java.lang.String,java.lang.String)(https://developer.android.com/reference/java/lang/String.html key, https://developer.android.com/reference/java/lang/String.html tag)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/State` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#setWidth(androidx.constraintlayout.core.state.Dimension)(https://developer.android.com/reference/androidx/constraintlayout/core/state/Dimension dimension)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/VerticalChainReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#verticalChain()()` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/VerticalChainReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#verticalChain(java.lang.Object...)(Object[] references)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/GuidelineReference` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#verticalGuideline(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html key)` |
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/State` | `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#width(androidx.constraintlayout.core.state.Dimension)(https://developer.android.com/reference/androidx/constraintlayout/core/state/Dimension dimension)` |

## Constants

### PARENT

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

```
public static final Integer PARENT
```

## Public fields

### mParent

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

```
public final ConstraintReference mParent
```

## Protected fields

### mHelperReferences

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

```
protected HashMap<Object, HelperReference> mHelperReferences
```

### mReferences

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

```
protected HashMap<Object, Reference> mReferences
```

## Public constructors

### State

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

```
public State()
```

## Public methods

### apply

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

```
public void apply(ConstraintWidgetContainer container)
```

### barrier

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

```
public BarrierReference barrier(Object key, State.Direction direction)
```

### baselineNeededFor

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

```
public void baselineNeededFor(Object id)
```

Baseline is needed for this object

### centerHorizontally

```
public AlignHorizontallyReference centerHorizontally(Object[] references)
```

### centerVertically

```
public AlignVerticallyReference centerVertically(Object[] references)
```

### constraints

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

```
public ConstraintReference constraints(Object key)
```

### convertDimension

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

```
public int convertDimension(Object value)
```

Implements a conversion function for values, returning int. This can be used in case values (e.g. margins) are represented via an object, not directly an int.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html value` | the object to convert from |

### createConstraintReference

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

```
public ConstraintReference createConstraintReference(Object key)
```

Create a new reference given a key.

### directMapping

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

```
public void directMapping()
```

### getFlow

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

```
public FlowReference getFlow(Object key, boolean vertical)
```

Gets a reference to a Flow object. Creating it if needed.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html key` | id of the reference |
| `boolean vertical` | is it a vertical or horizontal flow |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/FlowReference` | a FlowReference |

### getGrid

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

```
public @NonNull GridReference getGrid(@NonNull Object key, @NonNull String gridType)
```

Get a Grid reference

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html key` | name of the reference object |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html gridType` | type of Grid pattern - Grid, Row, or Column |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/GridReference` | a GridReference object |

### getHorizontalFlow

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

```
public FlowReference getHorizontalFlow()
```

Get a HorizontalFlowReference

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/FlowReference` | a HorizontalFlowReference |

### getHorizontalFlow

```
public FlowReference getHorizontalFlow(Object[] references)
```

Get a HorizontalFlowReference and add it to references

| Parameters |
|---|---|
| `Object[] references` | references where we the HorizontalFlowReference |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/FlowReference` | a HorizontalFlowReference |

### getIdsForTag

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

```
public ArrayList<String> getIdsForTag(String tag)
```

### getVerticalFlow

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

```
public FlowReference getVerticalFlow()
```

Get a VerticalFlowReference

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/FlowReference` | a VerticalFlowReference |

### getVerticalFlow

```
public FlowReference getVerticalFlow(Object[] references)
```

Get a VerticalFlowReference and add it to references

| Parameters |
|---|---|
| `Object[] references` | where we add the VerticalFlowReference |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/core/state/helpers/FlowReference` | a VerticalFlowReference |

### guideline

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

```
public GuidelineReference guideline(Object key, int orientation)
```

### height

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

```
public State height(Dimension dimension)
```

### helper

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

```
public HelperReference helper(Object key, State.Helper type)
```

### horizontalChain

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

```
public HorizontalChainReference horizontalChain()
```

### horizontalChain

```
public HorizontalChainReference horizontalChain(Object[] references)
```

### horizontalGuideline

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

```
public GuidelineReference horizontalGuideline(Object key)
```

### isBaselineNeeded

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

```
public boolean isBaselineNeeded(ConstraintWidget constraintWidget)
```

Does this constraintWidget need a baseline

| Returns |
|---|---|
| `boolean` | true if the constraintWidget needs a baseline |

### isLtr

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

```
public boolean [isLtr](https://developer.android.com/reference/androidx/constraintlayout/core/state/State#isLtr())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> For consistency, use `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#isRtl()` instead.

Returns true if layout direction is left to right. False for right to left.

### isRtl

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

```
public boolean isRtl()
```

Returns true if layout direction is right to left. False for left to right.

### map

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

```
public void map(Object key, Object view)
```

### reset

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

```
public void reset()
```

Clear the state

### sameFixedHeight

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

```
public boolean sameFixedHeight(int height)
```

### sameFixedWidth

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

```
public boolean sameFixedWidth(int width)
```

### setDpToPixel

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

```
public void setDpToPixel(CorePixelDp dpToPixel)
```

Set the function that converts dp to Pixels

### setHeight

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

```
public State setHeight(Dimension dimension)
```

### setLtr

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

```
public void [setLtr](https://developer.android.com/reference/androidx/constraintlayout/core/state/State#setLtr(boolean))(boolean isLtr)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> For consistency, use `https://developer.android.com/reference/androidx/constraintlayout/core/state/State#setRtl(boolean)` instead.

Set whether the layout direction is left to right (Ltr).

### setRtl

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

```
public void setRtl(boolean isRtl)
```

Set whether the layout direction is right to left (Rtl).

### setTag

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

```
public void setTag(String key, String tag)
```

### setWidth

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

```
public State setWidth(Dimension dimension)
```

### verticalChain

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

```
public VerticalChainReference verticalChain()
```

### verticalChain

```
public VerticalChainReference verticalChain(Object[] references)
```

### verticalGuideline

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

```
public GuidelineReference verticalGuideline(Object key)
```

### width

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

```
public State width(Dimension dimension)
```