Summary: [Fields](https://developer.android.com/reference/android/support/constraint/helper/Flow#lfields) \| [Ctors](https://developer.android.com/reference/android/support/constraint/helper/Flow#pubctors) \| [Methods](https://developer.android.com/reference/android/support/constraint/helper/Flow#pubmethods) \| [Protected Methods](https://developer.android.com/reference/android/support/constraint/helper/Flow#promethods) \| [Inherited Methods](https://developer.android.com/reference/android/support/constraint/helper/Flow#inhmethods)

# Flow


`
public


class
Flow
`


`


`

`

extends View


`

`


`

|---|---|---|
| java.lang.Object |||
| ↳ | View ||
|   | ↳ | android.support.constraint.helper.Flow |

<br />

*** ** * ** ***

Flow virtual layout.

**Added in 2.0**

Allows positioning of referenced widgets horizontally or vertically, similar to a Chain.

The elements referenced are indicated via constraint_referenced_ids, as with other ContraintHelper implementations.

Those referenced widgets are then laid out by the Flow virtual layout in three possible ways:

- [wrap none](https://developer.android.com/reference/android/support/constraint/helper/Flow#wrap_none) : simply create a chain out of the referenced elements
- [wrap chain](https://developer.android.com/reference/android/support/constraint/helper/Flow#wrap_chain) : create multiple chains (one after the other) if the referenced elements do not fit
- [wrap aligned](https://developer.android.com/reference/android/support/constraint/helper/Flow#wrap_aligned) : similar to wrap chain, but will align the elements by creating rows and columns

As VirtualLayout are ConstraintHelper, they are normal views; you can thus treat them as such, and setting up constraints on them (position, dimension) or some view attributes (background, padding) will work. The main difference between VirtualLayouts and ViewGroups is that:

<!-- -->

- VirtualLayout keep the hierarchy flat
- Other views can thus reference / constrain to not only the VirtualLayout, but also the views laid out by the VirtualLayout
- VirtualLayout allow on the fly behavior modifications (e.g. for Flow, chaing the orientation)

#### flow_wrapMode = "none"

This will simply create an horizontal or vertical chain out of the referenced widgets. This is the default behavior of Flow. XML attributes that are allowed in this mode:

- flow_horizontalStyle = "spread\|spread_inside\|packed"
- flow_verticalStyle = "spread\|spread_inside\|packed"
- flow_horizontalBias = "*float*"
- flow_verticalBias = "*float*"
- flow_horizontalGap = "*dimension*"
- flow_verticalGap = "*dimension*"
- flow_horizontalAlign = "start\|end\|center"
- flow_verticalAlign = "top\|bottom\|center\|baseline

While the elements are laid out as a chain in the orientation defined, the way they are laid out in the other dimension is controlled by *flow_horizontalAlign* and *flow_verticalAlign* attributes.

#### flow_wrapMode = "chain"

Similar to wrap none in terms of creating chains, but if the referenced widgets do not fit the horizontal or vertical dimension (depending on the orientation picked), they will wrap around to the next line / column. XML attributes are the same same as in wrap_none, with the addition of attributes specifying chain style and chain bias applied to the first chain. This way, it is possible to specify different chain behavior between the first chain and the rest of the chains eventually created.

- flow_firstHorizontalStyle = "spread\|spread_inside\|packed"
- flow_firstVerticalStyle = "spread\|spread_inside\|packed"
- flow_firstHorizontalBias = "*float*"
- flow_firstVerticalBias = "*float*"

One last important attribute is *flow_maxElementsWrap*, which specify the number of elements before wrapping, regardless if they fit or not in the available space.

#### flow_wrapMode = "aligned"

Same XML attributes as for WRAP_CHAIN, with the difference that the elements are going to be laid out in a set of rows and columns instead of chains. The attribute specifying chains style and bias are thus not going to be applied.

<br />

## Summary

| ### Fields ||
|---|---|
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#CHAIN_PACKED` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#CHAIN_SPREAD` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#CHAIN_SPREAD_INSIDE` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#HORIZONTAL` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#HORIZONTAL_ALIGN_CENTER` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#HORIZONTAL_ALIGN_END` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#HORIZONTAL_ALIGN_START` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#VERTICAL` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#VERTICAL_ALIGN_BASELINE` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#VERTICAL_ALIGN_BOTTOM` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#VERTICAL_ALIGN_CENTER` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#VERTICAL_ALIGN_TOP` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#WRAP_ALIGNED` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#WRAP_CHAIN` |
| ` public static final int` | `https://developer.android.com/reference/android/support/constraint/helper/Flow#WRAP_NONE` |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/support/constraint/helper/Flow#Flow(Context)(Context context) ` |
| ` https://developer.android.com/reference/android/support/constraint/helper/Flow#Flow(Context,%20AttributeSet)(Context context, AttributeSet attrs) ` |
| ` https://developer.android.com/reference/android/support/constraint/helper/Flow#Flow(Context,%20AttributeSet,%20int)(Context context, AttributeSet attrs, int defStyleAttr) ` |

| ### Public methods ||
|---|---|
| ` int[]` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#getReferencedIds()() ` Helpers typically reference a collection of ids |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#loadParameters(android.support.constraint.ConstraintSet.Constraint,%20HelperWidget,%20android.support.constraint.ConstraintLayout.LayoutParams,%20<any>)(https://developer.android.com/reference/android/support/constraint/ConstraintSet.Constraint constraint, HelperWidget child, https://developer.android.com/reference/android/support/constraint/ConstraintLayout.LayoutParams layoutParams, mapIdToWidget) ` |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#onMeasure(android.support.constraint.solver.widgets.VirtualLayout,%20int,%20int)(android.support.constraint.solver.widgets.VirtualLayout layout, int widthMeasureSpec, int heightMeasureSpec) ` |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#resolveRtl(ConstraintWidget,%20boolean)(ConstraintWidget widget, boolean isRtl) ` |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setFirstHorizontalBias(float)(float bias) ` Similar to setHorizontalBias(), but only applied to the first chain. |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setFirstHorizontalStyle(int)(int style) ` Similar to setHorizontalStyle(), but only applies to the first chain. |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setFirstVerticalBias(float)(float bias) ` Similar to setVerticalBias(), but only applied to the first chain. |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setFirstVerticalStyle(int)(int style) ` Similar to setVerticalStyle(), but only applies to the first chain. |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setHorizontalAlign(int)(int align) ` Set up the horizontal alignment of the elements in the layout, if the layout orientation is set to Flow.VERTICAL Can be either: Flow.HORIZONTAL_ALIGN_START Flow.HORIZONTAL_ALIGN_END Flow.HORIZONTAL_ALIGN_CENTER |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setHorizontalBias(float)(float bias) ` Set the horizontal bias applied to the chain |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setHorizontalGap(int)(int gap) ` Set up the horizontal gap between elements |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setHorizontalStyle(int)(int style) ` Set horizontal chain style. |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setMaxElementsWrap(int)(int max) ` Set up the maximum number of elements before wrapping. |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setOrientation(int)(int orientation) ` Set the orientation of the layout |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setPadding(int)(int padding) ` Set padding around the content |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setPaddingBottom(int)(int paddingBottom) ` Set padding bottom around the content |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setPaddingLeft(int)(int paddingLeft) ` Set padding left around the content |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setPaddingRight(int)(int paddingRight) ` Set padding right around the content |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setPaddingTop(int)(int paddingTop) ` Set padding top around the content |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setReferencedIds(int[])(int[] ids) ` Helpers typically reference a collection of ids |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setVerticalAlign(int)(int align) ` Set up the vertical alignment of the elements in the layout, if the layout orientation is set to Flow.HORIZONTAL Can be either: Flow.VERTICAL_ALIGN_TOP Flow.VERTICAL_ALIGN_BOTTOM Flow.VERTICAL_ALIGN_CENTER Flow.VERTICAL_ALIGN_BASELINE |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setVerticalBias(float)(float bias) ` Set the vertical bias applied to the chain |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setVerticalGap(int)(int gap) ` Set up the vertical gap between elements |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setVerticalStyle(int)(int style) ` Set vertical chain style. |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#setWrapMode(int)(int mode) ` Set wrap mode for the layout. |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#updatePostConstraints(android.support.constraint.ConstraintLayout)(https://developer.android.com/reference/android/support/constraint/ConstraintLayout constainer) ` |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#updatePreLayout(ConstraintWidgetContainer,%20Helper,%20<any>)(ConstraintWidgetContainer container, Helper helper, map) ` |

| ### Protected methods ||
|---|---|
| ` View[]` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#getViews(android.support.constraint.ConstraintLayout)(https://developer.android.com/reference/android/support/constraint/ConstraintLayout layout) ` |
| ` void` | ` https://developer.android.com/reference/android/support/constraint/helper/Flow#onMeasure(int,%20int)(int widthMeasureSpec, int heightMeasureSpec) ` |

### Inherited methods

From class `

java.lang.Object

` `


Object` `
clone()
` `


boolean` `
equals(Object arg0)
` `


void` `
finalize()
` `


final

Class<?>` `
getClass()
` `


int` `
hashCode()
` `


final

void` `
notify()
` `


final

void` `
notifyAll()
` `


String` `
toString()
` `


final

void` `
wait(long arg0, int arg1)
` `


final

void` `
wait(long arg0)
` `


final

void` `
wait()
`

## Fields

### CHAIN_PACKED

```
public static final int CHAIN_PACKED
```

<br />

<br />

### CHAIN_SPREAD

```
public static final int CHAIN_SPREAD
```

<br />

<br />

### CHAIN_SPREAD_INSIDE

```
public static final int CHAIN_SPREAD_INSIDE
```

<br />

<br />

### HORIZONTAL

```
public static final int HORIZONTAL
```

<br />

<br />

### HORIZONTAL_ALIGN_CENTER

```
public static final int HORIZONTAL_ALIGN_CENTER
```

<br />

<br />

### HORIZONTAL_ALIGN_END

```
public static final int HORIZONTAL_ALIGN_END
```

<br />

<br />

### HORIZONTAL_ALIGN_START

```
public static final int HORIZONTAL_ALIGN_START
```

<br />

<br />

### VERTICAL

```
public static final int VERTICAL
```

<br />

<br />

### VERTICAL_ALIGN_BASELINE

```
public static final int VERTICAL_ALIGN_BASELINE
```

<br />

<br />

### VERTICAL_ALIGN_BOTTOM

```
public static final int VERTICAL_ALIGN_BOTTOM
```

<br />

<br />

### VERTICAL_ALIGN_CENTER

```
public static final int VERTICAL_ALIGN_CENTER
```

<br />

<br />

### VERTICAL_ALIGN_TOP

```
public static final int VERTICAL_ALIGN_TOP
```

<br />

<br />

### WRAP_ALIGNED

```
public static final int WRAP_ALIGNED
```

<br />

<br />

### WRAP_CHAIN

```
public static final int WRAP_CHAIN
```

<br />

<br />

### WRAP_NONE

```
public static final int WRAP_NONE
```

<br />

<br />

## Public constructors

### Flow

```
public Flow (Context context)
```

<br />

<br />

| Parameters ||
|---|---|
| `context` | `Context` <br /> |

### Flow

```
public Flow (Context context, 
                AttributeSet attrs)
```

<br />

<br />

| Parameters ||
|---|---|
| `context` | `Context` <br /> |
| `attrs` | `AttributeSet` <br /> |

### Flow

```
public Flow (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)
```

<br />

<br />

| Parameters ||
|---|---|
| `context` | `Context` <br /> |
| `attrs` | `AttributeSet` <br /> |
| `defStyleAttr` | `int` <br /> |

## Public methods

### getReferencedIds

```
public int[] getReferencedIds ()
```

Helpers typically reference a collection of ids

<br />

| Returns ||
|---|---|
| `int[]` | ids referenced <br /> |

### loadParameters

```
public void loadParameters (ConstraintSet.Constraint constraint, 
                HelperWidget child, 
                ConstraintLayout.LayoutParams layoutParams, 
                 mapIdToWidget)
```

<br />

<br />

| Parameters ||
|---|---|
| `constraint` | `ConstraintSet.Constraint` <br /> |
| `child` | `HelperWidget` <br /> |
| `layoutParams` | `ConstraintLayout.LayoutParams` <br /> |
| `mapIdToWidget` | <br /> |

### onMeasure

```
public void onMeasure (android.support.constraint.solver.widgets.VirtualLayout layout, 
                int widthMeasureSpec, 
                int heightMeasureSpec)
```

<br />

<br />

| Parameters ||
|---|---|
| `layout` | `android.support.constraint.solver.widgets.VirtualLayout` <br /> |
| `widthMeasureSpec` | `int` <br /> |
| `heightMeasureSpec` | `int` <br /> |

### resolveRtl

```
public void resolveRtl (ConstraintWidget widget, 
                boolean isRtl)
```

<br />

<br />

| Parameters ||
|---|---|
| `widget` | `ConstraintWidget` <br /> |
| `isRtl` | `boolean` <br /> |

### setFirstHorizontalBias

```
public void setFirstHorizontalBias (float bias)
```

Similar to setHorizontalBias(), but only applied to the first chain.

<br />

### setFirstHorizontalStyle

```
public void setFirstHorizontalStyle (int style)
```

Similar to setHorizontalStyle(), but only applies to the first chain.

<br />

### setFirstVerticalBias

```
public void setFirstVerticalBias (float bias)
```

Similar to setVerticalBias(), but only applied to the first chain.

<br />

### setFirstVerticalStyle

```
public void setFirstVerticalStyle (int style)
```

Similar to setVerticalStyle(), but only applies to the first chain.

<br />

### setHorizontalAlign

```
public void setHorizontalAlign (int align)
```

Set up the horizontal alignment of the elements in the layout, if the layout orientation is set to Flow.VERTICAL

Can be either:
Flow.HORIZONTAL_ALIGN_START
Flow.HORIZONTAL_ALIGN_END
Flow.HORIZONTAL_ALIGN_CENTER

<br />

### setHorizontalBias

```
public void setHorizontalBias (float bias)
```

Set the horizontal bias applied to the chain

<br />

| Parameters ||
|---|---|
| `bias` | `float`: from 0 to 1 <br /> |

### setHorizontalGap

```
public void setHorizontalGap (int gap)
```

Set up the horizontal gap between elements

<br />

### setHorizontalStyle

```
public void setHorizontalStyle (int style)
```

Set horizontal chain style. Can be:

Flow.CHAIN_SPREAD
Flow.CHAIN_SPREAD_INSIDE
Flow.CHAIN_PACKED

<br />

### setMaxElementsWrap

```
public void setMaxElementsWrap (int max)
```

Set up the maximum number of elements before wrapping.

<br />

### setOrientation

```
public void setOrientation (int orientation)
```

Set the orientation of the layout

<br />

| Parameters ||
|---|---|
| `orientation` | `int`: either Flow.HORIZONTAL or FLow.VERTICAL <br /> |

### setPadding

```
public void setPadding (int padding)
```

Set padding around the content

<br />

### setPaddingBottom

```
public void setPaddingBottom (int paddingBottom)
```

Set padding bottom around the content

<br />

### setPaddingLeft

```
public void setPaddingLeft (int paddingLeft)
```

Set padding left around the content

<br />

### setPaddingRight

```
public void setPaddingRight (int paddingRight)
```

Set padding right around the content

<br />

### setPaddingTop

```
public void setPaddingTop (int paddingTop)
```

Set padding top around the content

<br />

### setReferencedIds

```
public void setReferencedIds (int[] ids)
```

Helpers typically reference a collection of ids

<br />

| Parameters ||
|---|---|
| `ids` | `int` <br /> |

| Returns ||
|---|---|
| `void` | ids referenced <br /> |

### setVerticalAlign

```
public void setVerticalAlign (int align)
```

Set up the vertical alignment of the elements in the layout, if the layout orientation is set to Flow.HORIZONTAL

Can be either:
Flow.VERTICAL_ALIGN_TOP
Flow.VERTICAL_ALIGN_BOTTOM
Flow.VERTICAL_ALIGN_CENTER
Flow.VERTICAL_ALIGN_BASELINE

<br />

### setVerticalBias

```
public void setVerticalBias (float bias)
```

Set the vertical bias applied to the chain

<br />

| Parameters ||
|---|---|
| `bias` | `float`: from 0 to 1 <br /> |

### setVerticalGap

```
public void setVerticalGap (int gap)
```

Set up the vertical gap between elements

<br />

### setVerticalStyle

```
public void setVerticalStyle (int style)
```

Set vertical chain style. Can be:

Flow.CHAIN_SPREAD
Flow.CHAIN_SPREAD_INSIDE
Flow.CHAIN_PACKED

<br />

### setWrapMode

```
public void setWrapMode (int mode)
```

Set wrap mode for the layout. Can be:

Flow.WRAP_NONE (default) -- no wrap behavior, create a single chain
Flow.WRAP_CHAIN -- if not enough space to fit the referenced elements, will create additional chains after the first one
Flow.WRAP_ALIGNED -- if not enough space to fit the referenced elements, will wrap the elements, keeping them aligned (like a table)

<br />

### updatePostConstraints

```
public void updatePostConstraints (ConstraintLayout constainer)
```

<br />

<br />

| Parameters ||
|---|---|
| `constainer` | `ConstraintLayout` <br /> |

### updatePreLayout

```
public void updatePreLayout (ConstraintWidgetContainer container, 
                Helper helper, 
                 map)
```

<br />

<br />

| Parameters ||
|---|---|
| `container` | `ConstraintWidgetContainer` <br /> |
| `helper` | `Helper` <br /> |
| `map` | <br /> |

## Protected methods

### getViews

```
protected View[] getViews (ConstraintLayout layout)
```

<br />

<br />

| Parameters ||
|---|---|
| `layout` | `ConstraintLayout` <br /> |

| Returns ||
|---|---|
| `View[]` | <br /> |

### onMeasure

```
protected void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)
```

<br />

<br />

| Parameters ||
|---|---|
| `widthMeasureSpec` | `int` <br /> |
| `heightMeasureSpec` | `int` <br /> |