# ConstraintAttribute

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

*** ** * ** ***


```
public class ConstraintAttribute
```

<br />

*** ** * ** ***

Defines non standard Attributes

## Summary

| ### Nested types |
|---|
| `public enum https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute.AttributeType` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#ConstraintAttribute(java.lang.String,androidx.constraintlayout.widget.ConstraintAttribute.AttributeType)( https://developer.android.com/reference/java/lang/String.html name, https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute.AttributeType attributeType )` |
| `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#ConstraintAttribute(androidx.constraintlayout.widget.ConstraintAttribute,java.lang.Object)(https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute source, https://developer.android.com/reference/java/lang/Object.html value)` |
| `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#ConstraintAttribute(java.lang.String,androidx.constraintlayout.widget.ConstraintAttribute.AttributeType,java.lang.Object,boolean)( https://developer.android.com/reference/java/lang/String.html name, https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute.AttributeType attributeType, https://developer.android.com/reference/java/lang/Object.html value, boolean method )` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#applyCustom(android.view.View)(https://developer.android.com/reference/android/view/View.html view)` Apply custom attributes to the view |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#diff(androidx.constraintlayout.widget.ConstraintAttribute)(https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute constraintAttribute)` test if the two attributes are different |
| `static 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/widget/ConstraintAttribute>` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#extractAttributes(java.util.HashMap<java.lang.String,androidx.constraintlayout.widget.ConstraintAttribute>,android.view.View)(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/widget/ConstraintAttribute> base, https://developer.android.com/reference/android/view/View.html view)` extract attributes from the view |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#getColorValue()()` |
| `float` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#getFloatValue()()` |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#getIntegerValue()()` |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#getName()()` |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#getStringValue()()` |
| `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute.AttributeType` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#getType()()` |
| `float` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#getValueToInterpolate()()` Transforms value to a float for the purpose of interpolation |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#getValuesToInterpolate(float[])(float[] ret)` populate the float array with colors it will fill 4 values |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#isBooleanValue()()` |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#isContinuous()()` Continuous types are interpolated they are fired only at |
| `boolean` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#isMethod()()` |
| `int` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#numberOfInterpolatedValues()()` The number of interpolation values that need to be interpolated Typically 1 but 3 for colors. |
| `static void` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#parse(android.content.Context,org.xmlpull.v1.XmlPullParser,java.util.HashMap<java.lang.String,androidx.constraintlayout.widget.ConstraintAttribute>)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html parser, 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/widget/ConstraintAttribute> custom )` parse Custom attributes and fill Custom |
| `static void` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#setAttributes(android.view.View,java.util.HashMap<java.lang.String,androidx.constraintlayout.widget.ConstraintAttribute>)(https://developer.android.com/reference/android/view/View.html view, 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/widget/ConstraintAttribute> map)` set attributes from map on to the view |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#setColorValue(int)(int value)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#setFloatValue(float)(float value)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#setIntValue(int)(int value)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#setStringValue(java.lang.String)(https://developer.android.com/reference/java/lang/String.html value)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#setValue(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html value)` set the value based on casting the object |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute#setValue(float[])(float[] value)` setValue based on the values in the array |

## Public constructors

### ConstraintAttribute

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

```
public ConstraintAttribute(
    String name,
    ConstraintAttribute.AttributeType attributeType
)
```

### ConstraintAttribute

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

```
public ConstraintAttribute(ConstraintAttribute source, Object value)
```

### ConstraintAttribute

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

```
public ConstraintAttribute(
    String name,
    ConstraintAttribute.AttributeType attributeType,
    Object value,
    boolean method
)
```

## Public methods

### applyCustom

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

```
public void applyCustom(View view)
```

Apply custom attributes to the view

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/view/View.html view` |   |

### diff

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

```
public boolean diff(ConstraintAttribute constraintAttribute)
```

test if the two attributes are different

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintAttribute constraintAttribute` |   |

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

### extractAttributes

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

```
public static HashMap<String, ConstraintAttribute> extractAttributes(HashMap<String, ConstraintAttribute> base, View view)
```

extract attributes from the view

| 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/widget/ConstraintAttribute> base` |   |
| `https://developer.android.com/reference/android/view/View.html view` |   |

| Returns |
|---|---|
| `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/widget/ConstraintAttribute>` |   |

### getColorValue

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

```
public int getColorValue()
```

### getFloatValue

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

```
public float getFloatValue()
```

### getIntegerValue

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

```
public int getIntegerValue()
```

### getName

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

```
public String getName()
```

### getStringValue

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

```
public String getStringValue()
```

### getType

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

```
public ConstraintAttribute.AttributeType getType()
```

### getValueToInterpolate

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

```
public float getValueToInterpolate()
```

Transforms value to a float for the purpose of interpolation

| Returns |
|---|---|
| `float` | interpolation value |

### getValuesToInterpolate

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

```
public void getValuesToInterpolate(float[] ret)
```

populate the float array with colors it will fill 4 values

| Parameters |
|---|---|
| `float[] ret` |   |

### isBooleanValue

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

```
public boolean isBooleanValue()
```

### isContinuous

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

```
public boolean isContinuous()
```

Continuous types are interpolated they are fired only at

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

### isMethod

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

```
public boolean isMethod()
```

### numberOfInterpolatedValues

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

```
public int numberOfInterpolatedValues()
```

The number of interpolation values that need to be interpolated Typically 1 but 3 for colors.

| Returns |
|---|---|
| `int` | Typically 1 but 3 for colors. |

### parse

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

```
public static void parse(
    Context context,
    XmlPullParser parser,
    HashMap<String, ConstraintAttribute> custom
)
```

parse Custom attributes and fill Custom

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` |   |
| `https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html parser` |   |
| `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/widget/ConstraintAttribute> custom` |   |

### setAttributes

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

```
public static void setAttributes(View view, HashMap<String, ConstraintAttribute> map)
```

set attributes from map on to the view

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/view/View.html view` |   |
| `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/widget/ConstraintAttribute> map` |   |

### setColorValue

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

```
public void setColorValue(int value)
```

### setFloatValue

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

```
public void setFloatValue(float value)
```

### setIntValue

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

```
public void setIntValue(int value)
```

### setStringValue

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

```
public void setStringValue(String value)
```

### setValue

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

```
public void setValue(Object value)
```

set the value based on casting the object

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

### setValue

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

```
public void setValue(float[] value)
```

setValue based on the values in the array

| Parameters |
|---|---|
| `float[] value` |   |