# StateSet

Artifact: [androidx.constraintlayout:constraintlayout](https://developer.android.com/jetpack/androidx/releases/constraintlayout) [View Source](https://cs.android.com/search?q=file:androidx/constraintlayout/widget/StateSet.java+class:androidx.constraintlayout.widget.StateSet) Added in [2.2.2](https://developer.android.com/jetpack/androidx/releases/constraintlayout#2.2.2)

*** ** * ** ***


```
class StateSet
```

<br />

*** ** * ** ***

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/widget/StateSet#TAG() = "ConstraintLayoutStates"` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/constraintlayout/widget/StateSet#StateSet(android.content.Context,org.xmlpull.v1.XmlPullParser)(context: https://developer.android.com/reference/android/content/Context.html!, parser: https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html!)` Parse a StateSet |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/widget/StateSet#convertToConstraintSet(int,int,float,float)( currentConstrainSettId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, stateId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` converts a state to a constraintSet |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/widget/StateSet#needsToChange(int,float,float)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` will the layout need to change |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/widget/StateSet#setOnConstraintsChanged(androidx.constraintlayout.widget.ConstraintsChangedListener)( constraintsChangedListener: https://developer.android.com/reference/kotlin/androidx/constraintlayout/widget/ConstraintsChangedListener! )` listen for changes in constraintSet |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/widget/StateSet#stateGetConstraintID(int,int,int)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Get the constraint id for a state |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/constraintlayout/widget/StateSet#updateConstraints(int,int,float,float)(currentId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Update the Constraints |

## Constants

### TAG

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

```
const val TAG = "ConstraintLayoutStates": String!
```

## Public constructors

### StateSet

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

```
StateSet(context: Context!, parser: XmlPullParser!)
```

Parse a StateSet

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html!` |   |
| `parser: https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html!` |   |

## Public functions

### convertToConstraintSet

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

```
fun convertToConstraintSet(
    currentConstrainSettId: Int,
    stateId: Int,
    width: Float,
    height: Float
): Int
```

converts a state to a constraintSet

| Parameters |
|---|---|
| `currentConstrainSettId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` |   |
| `stateId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` |   |
| `width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` |   |
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` |   |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` |   |

### needsToChange

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

```
fun needsToChange(id: Int, width: Float, height: Float): Boolean
```

will the layout need to change

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` |   |
| `width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` |   |
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` |   |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` |   |

### setOnConstraintsChanged

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

```
fun setOnConstraintsChanged(
    constraintsChangedListener: ConstraintsChangedListener!
): Unit
```

listen for changes in constraintSet

| Parameters |
|---|---|
| `constraintsChangedListener: https://developer.android.com/reference/kotlin/androidx/constraintlayout/widget/ConstraintsChangedListener!` |   |

### stateGetConstraintID

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

```
fun stateGetConstraintID(id: Int, width: Int, height: Int): Int
```

Get the constraint id for a state

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` |   |
| `width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` |   |
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` |   |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` |   |

### updateConstraints

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

```
fun updateConstraints(currentId: Int, id: Int, width: Float, height: Float): Int
```

Update the Constraints

| Parameters |
|---|---|
| `currentId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` |   |
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` |   |
| `width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` |   |
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` |   |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` |   |