Flow
class Flow : VirtualLayout
| kotlin.Any | ||||
| ↳ | android.view.View | |||
| ↳ | androidx.constraintlayout.widget.ConstraintHelper | |||
| ↳ | androidx.constraintlayout.widget.VirtualLayout | |||
| ↳ | androidx.constraintlayout.helper.widget.Flow |
Flow VirtualLayout. 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 ConstraintHelper implementations. Those referenced widgets are then laid out by the Flow virtual layout in three possible ways:
- wrap none : simply create a chain out of the referenced elements
- wrap chain : create multiple chains (one after the other) if the referenced elements do not fit
- wrap aligned : similar to wrap chain, but will align the elements by creating rows and columns
- 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, changing 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"
- flow_verticalAlign = "top|bottom|center|baseline
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"
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.Summary
Constants |
|
|---|---|
const Int |
CHAIN_PACKED = 2 |
const Int |
CHAIN_SPREAD = 0 |
const Int |
|
const Int |
HORIZONTAL = 0 |
const Int |
|
const Int |
|
const Int |
|
const Int |
VERTICAL = 1 |
const Int |
|
const Int |
|
const Int |
|
const Int |
|
const Int |
WRAP_ALIGNED = 2 |
const Int |
WRAP_CHAIN = 1 |
const Int |
WRAP_NONE = 0 |
Public constructors |
|---|
Flow(context: Context!, attrs: AttributeSet!) |
Flow(context: Context!, attrs: AttributeSet!, defStyleAttr: Int) |
Public functions |
|
|---|---|
Unit |
loadParameters( |
Unit |
onMeasure( |
Unit |
resolveRtl(widget: ConstraintWidget!, isRtl: Boolean) |
Unit |
setFirstHorizontalBias(bias: Float)Similar to setHorizontalBias(), but only applied to the first chain. |
Unit |
setFirstHorizontalStyle(style: Int)Similar to setHorizontalStyle(), but only applies to the first chain. |
Unit |
setFirstVerticalBias(bias: Float)Similar to setVerticalBias(), but only applied to the first chain. |
Unit |
setFirstVerticalStyle(style: Int)Similar to setVerticalStyle(), but only applies to the first chain. |
Unit |
setHorizontalAlign(align: Int)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 |
Unit |
setHorizontalBias(bias: Float)Set the horizontal bias applied to the chain |
Unit |
setHorizontalGap(gap: Int)Set up the horizontal gap between elements |
Unit |
setHorizontalStyle(style: Int)Set horizontal chain style. |
Unit |
setLastHorizontalBias(bias: Float)Set the bias of the last Horizontal column. |
Unit |
setLastHorizontalStyle(style: Int)Set the style of the last Horizontal column. |
Unit |
setLastVerticalBias(bias: Float)Set the bias of the last vertical row. |
Unit |
setLastVerticalStyle(style: Int)Set the style of the last vertical row. |
Unit |
setMaxElementsWrap(max: Int)Set up the maximum number of elements before wrapping. |
Unit |
setOrientation(orientation: Int)Set the orientation of the layout |
Unit |
setPadding(padding: Int)Set padding around the content |
Unit |
setPaddingBottom(paddingBottom: Int)Set padding bottom around the content |
Unit |
setPaddingLeft(paddingLeft: Int)Set padding left around the content |
Unit |
setPaddingRight(paddingRight: Int)Set padding right around the content |
Unit |
setPaddingTop(paddingTop: Int)Set padding top around the content |
Unit |
setVerticalAlign(align: Int)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 |
Unit |
setVerticalBias(bias: Float)Set the vertical bias applied to the chain |
Unit |
setVerticalGap(gap: Int)Set up the vertical gap between elements |
Unit |
setVerticalStyle(style: Int)Set vertical chain style. |
Unit |
setWrapMode(mode: Int)Set wrap mode for the layout. |
Protected functions |
|
|---|---|
Unit |
init(attrs: AttributeSet!) |
Unit |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited properties |
|---|
Constants
Public constructors
Public functions
loadParameters
fun loadParameters(
constraint: ConstraintSet.Constraint!,
child: HelperWidget!,
layoutParams: ConstraintLayout.LayoutParams!,
mapIdToWidget: SparseArray<ConstraintWidget!>!
): Unit
| Parameters | |
|---|---|
constraint: ConstraintSet.Constraint! |
|
child: HelperWidget! |
|
layoutParams: ConstraintLayout.LayoutParams! |
|
mapIdToWidget: SparseArray<ConstraintWidget!>! |
onMeasure
fun onMeasure(
layout: VirtualLayout!,
widthMeasureSpec: Int,
heightMeasureSpec: Int
): Unit
| Parameters | |
|---|---|
layout: VirtualLayout! |
|
widthMeasureSpec: Int |
|
heightMeasureSpec: Int |
resolveRtl
fun resolveRtl(widget: ConstraintWidget!, isRtl: Boolean): Unit
| Parameters | |
|---|---|
widget: ConstraintWidget! |
|
isRtl: Boolean |
setFirstHorizontalBias
fun setFirstHorizontalBias(bias: Float): Unit
Similar to setHorizontalBias(), but only applied to the first chain.
| Parameters | |
|---|---|
bias: Float |
setFirstHorizontalStyle
fun setFirstHorizontalStyle(style: Int): Unit
Similar to setHorizontalStyle(), but only applies to the first chain.
| Parameters | |
|---|---|
style: Int |
setFirstVerticalBias
fun setFirstVerticalBias(bias: Float): Unit
Similar to setVerticalBias(), but only applied to the first chain.
| Parameters | |
|---|---|
bias: Float |
setFirstVerticalStyle
fun setFirstVerticalStyle(style: Int): Unit
Similar to setVerticalStyle(), but only applies to the first chain.
| Parameters | |
|---|---|
style: Int |
setHorizontalAlign
fun setHorizontalAlign(align: Int): Unit
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
| Parameters | |
|---|---|
align: Int |
setHorizontalBias
fun setHorizontalBias(bias: Float): Unit
Set the horizontal bias applied to the chain
| Parameters | |
|---|---|
bias: Float |
from 0 to 1 |
setHorizontalGap
fun setHorizontalGap(gap: Int): Unit
Set up the horizontal gap between elements
| Parameters | |
|---|---|
gap: Int |
setHorizontalStyle
fun setHorizontalStyle(style: Int): Unit
Set horizontal chain style. Can be: Flow.CHAIN_SPREAD Flow.CHAIN_SPREAD_INSIDE Flow.CHAIN_PACKED
| Parameters | |
|---|---|
style: Int |
setLastHorizontalBias
fun setLastHorizontalBias(bias: Float): Unit
Set the bias of the last Horizontal column.
| Parameters | |
|---|---|
bias: Float |
setLastHorizontalStyle
fun setLastHorizontalStyle(style: Int): Unit
Set the style of the last Horizontal column.
| Parameters | |
|---|---|
style: Int |
Flow.CHAIN_SPREAD, Flow.CHAIN_SPREAD_INSIDE, or Flow.CHAIN_PACKED |
setLastVerticalBias
fun setLastVerticalBias(bias: Float): Unit
Set the bias of the last vertical row.
| Parameters | |
|---|---|
bias: Float |
setLastVerticalStyle
fun setLastVerticalStyle(style: Int): Unit
Set the style of the last vertical row.
| Parameters | |
|---|---|
style: Int |
Flow.CHAIN_SPREAD, Flow.CHAIN_SPREAD_INSIDE, or Flow.CHAIN_PACKED |
setMaxElementsWrap
fun setMaxElementsWrap(max: Int): Unit
Set up the maximum number of elements before wrapping.
| Parameters | |
|---|---|
max: Int |
setOrientation
fun setOrientation(orientation: Int): Unit
Set the orientation of the layout
| Parameters | |
|---|---|
orientation: Int |
either Flow.HORIZONTAL or FLow.VERTICAL |
setPadding
fun setPadding(padding: Int): Unit
Set padding around the content
| Parameters | |
|---|---|
padding: Int |
setPaddingBottom
fun setPaddingBottom(paddingBottom: Int): Unit
Set padding bottom around the content
| Parameters | |
|---|---|
paddingBottom: Int |
setPaddingLeft
fun setPaddingLeft(paddingLeft: Int): Unit
Set padding left around the content
| Parameters | |
|---|---|
paddingLeft: Int |
setPaddingRight
fun setPaddingRight(paddingRight: Int): Unit
Set padding right around the content
| Parameters | |
|---|---|
paddingRight: Int |
setPaddingTop
fun setPaddingTop(paddingTop: Int): Unit
Set padding top around the content
| Parameters | |
|---|---|
paddingTop: Int |
setVerticalAlign
fun setVerticalAlign(align: Int): Unit
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
| Parameters | |
|---|---|
align: Int |
setVerticalBias
fun setVerticalBias(bias: Float): Unit
Set the vertical bias applied to the chain
| Parameters | |
|---|---|
bias: Float |
from 0 to 1 |
setVerticalGap
fun setVerticalGap(gap: Int): Unit
Set up the vertical gap between elements
| Parameters | |
|---|---|
gap: Int |
setVerticalStyle
fun setVerticalStyle(style: Int): Unit
Set vertical chain style. Can be: Flow.CHAIN_SPREAD Flow.CHAIN_SPREAD_INSIDE Flow.CHAIN_PACKED
| Parameters | |
|---|---|
style: Int |
setWrapMode
fun setWrapMode(mode: Int): Unit
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)
| Parameters | |
|---|---|
mode: Int |