# Ref

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

*** ** * ** ***


```
public class Ref
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static void` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#addStringToReferences(java.lang.String,java.util.ArrayList<androidx.constraintlayout.core.dsl.Ref>)(https://developer.android.com/reference/java/lang/String.html str, https://developer.android.com/reference/java/util/ArrayList.html<https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref> refs)` Add references in a String representation to a Ref ArrayList Used to add the Ref(s) property in the Config to references |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#getId()()` Get the Id of the reference |
| `float` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#getPostMargin()()` Get the postMargin of the reference |
| `float` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#getPreMargin()()` Get the preMargin of the reference |
| `float` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#getWeight()()` Get the weight of the reference |
| `static float` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#parseFloat(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html obj)` Try to parse an object into a float number |
| `static https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#parseStringToRef(java.lang.String)(https://developer.android.com/reference/java/lang/String.html str)` |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#setId(java.lang.String)(https://developer.android.com/reference/java/lang/String.html id)` Set the Id of the reference |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#setPostMargin(float)(float postMargin)` Set the postMargin of the reference |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#setPreMargin(float)(float preMargin)` Set the preMargin of the reference |
| `void` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#setWeight(float)(float weight)` Set the weight of the reference |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref#toString()()` |

## Public methods

### addStringToReferences

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

```
public static void addStringToReferences(String str, ArrayList<Ref> refs)
```

Add references in a String representation to a Ref ArrayList Used to add the Ref(s) property in the Config to references

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html str` | references in a String representation |
| `https://developer.android.com/reference/java/util/ArrayList.html<https://developer.android.com/reference/androidx/constraintlayout/core/dsl/Ref> refs` | a Ref ArrayList |

### getId

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

```
public String getId()
```

Get the Id of the reference

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

### getPostMargin

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

```
public float getPostMargin()
```

Get the postMargin of the reference

| Returns |
|---|---|
| `float` | the preMargin of the reference |

### getPreMargin

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

```
public float getPreMargin()
```

Get the preMargin of the reference

| Returns |
|---|---|
| `float` | the preMargin of the reference |

### getWeight

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

```
public float getWeight()
```

Get the weight of the reference

| Returns |
|---|---|
| `float` | the weight of the reference |

### parseFloat

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

```
public static float parseFloat(Object obj)
```

Try to parse an object into a float number

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html obj` | object to be parsed |

| Returns |
|---|---|
| `float` | a number |

### parseStringToRef

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

```
public static Ref parseStringToRef(String str)
```

### setId

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

```
public void setId(String id)
```

Set the Id of the reference

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

### setPostMargin

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

```
public void setPostMargin(float postMargin)
```

Set the postMargin of the reference

| Parameters |
|---|---|
| `float postMargin` |   |

### setPreMargin

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

```
public void setPreMargin(float preMargin)
```

Set the preMargin of the reference

| Parameters |
|---|---|
| `float preMargin` |   |

### setWeight

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

```
public void setWeight(float weight)
```

Set the weight of the reference

| Parameters |
|---|---|
| `float weight` |   |

### toString

```
public String toString()
```