Flow
public class Flow extends VirtualLayout
| java.lang.Object | ||||
| ↳ | 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 |
|
|---|---|
static final int |
CHAIN_PACKED = 2 |
static final int |
CHAIN_SPREAD = 0 |
static final int |
|
static final int |
HORIZONTAL = 0 |
static final int |
|
static final int |
|
static final int |
|
static final int |
VERTICAL = 1 |
static final int |
|
static final int |
|
static final int |
|
static final int |
|
static final int |
WRAP_ALIGNED = 2 |
static final int |
WRAP_CHAIN = 1 |
static final int |
WRAP_NONE = 0 |
Public constructors |
|---|
Flow(Context context, AttributeSet attrs) |
Flow(Context context, AttributeSet attrs, int defStyleAttr) |
Public methods |
|
|---|---|
void |
loadParameters( |
void |
onMeasure( |
void |
resolveRtl(ConstraintWidget widget, boolean isRtl) |
void |
setFirstHorizontalBias(float bias)Similar to setHorizontalBias(), but only applied to the first chain. |
void |
setFirstHorizontalStyle(int style)Similar to setHorizontalStyle(), but only applies to the first chain. |
void |
setFirstVerticalBias(float bias)Similar to setVerticalBias(), but only applied to the first chain. |
void |
setFirstVerticalStyle(int style)Similar to setVerticalStyle(), but only applies to the first chain. |
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 |
void |
setHorizontalBias(float bias)Set the horizontal bias applied to the chain |
void |
setHorizontalGap(int gap)Set up the horizontal gap between elements |
void |
setHorizontalStyle(int style)Set horizontal chain style. |
void |
setLastHorizontalBias(float bias)Set the bias of the last Horizontal column. |
void |
setLastHorizontalStyle(int style)Set the style of the last Horizontal column. |
void |
setLastVerticalBias(float bias)Set the bias of the last vertical row. |
void |
setLastVerticalStyle(int style)Set the style of the last vertical row. |
void |
setMaxElementsWrap(int max)Set up the maximum number of elements before wrapping. |
void |
setOrientation(int orientation)Set the orientation of the layout |
void |
setPadding(int padding)Set padding around the content |
void |
setPaddingBottom(int paddingBottom)Set padding bottom around the content |
void |
setPaddingLeft(int paddingLeft)Set padding left around the content |
void |
setPaddingRight(int paddingRight)Set padding right around the content |
void |
setPaddingTop(int paddingTop)Set padding top around the content |
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 |
void |
setVerticalBias(float bias)Set the vertical bias applied to the chain |
void |
setVerticalGap(int gap)Set up the vertical gap between elements |
void |
setVerticalStyle(int style)Set vertical chain style. |
void |
setWrapMode(int mode)Set wrap mode for the layout. |
Protected methods |
|
|---|---|
void |
init(AttributeSet attrs) |
void |
onMeasure(int widthMeasureSpec, int heightMeasureSpec) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited methods |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
Public constructors
Public methods
loadParameters
public void loadParameters(
ConstraintSet.Constraint constraint,
HelperWidget child,
ConstraintLayout.LayoutParams layoutParams,
SparseArray<ConstraintWidget> mapIdToWidget
)
| Parameters | |
|---|---|
ConstraintSet.Constraint constraint |
|
HelperWidget child |
|
ConstraintLayout.LayoutParams layoutParams |
|
SparseArray<ConstraintWidget> mapIdToWidget |
onMeasure
public void onMeasure(
VirtualLayout layout,
int widthMeasureSpec,
int heightMeasureSpec
)
| Parameters | |
|---|---|
VirtualLayout layout |
|
int widthMeasureSpec |
|
int heightMeasureSpec |
resolveRtl
public void resolveRtl(ConstraintWidget widget, boolean isRtl)
| Parameters | |
|---|---|
ConstraintWidget widget |
|
boolean isRtl |
setFirstHorizontalBias
public void setFirstHorizontalBias(float bias)
Similar to setHorizontalBias(), but only applied to the first chain.
| Parameters | |
|---|---|
float bias |
setFirstHorizontalStyle
public void setFirstHorizontalStyle(int style)
Similar to setHorizontalStyle(), but only applies to the first chain.
| Parameters | |
|---|---|
int style |
setFirstVerticalBias
public void setFirstVerticalBias(float bias)
Similar to setVerticalBias(), but only applied to the first chain.
| Parameters | |
|---|---|
float bias |
setFirstVerticalStyle
public void setFirstVerticalStyle(int style)
Similar to setVerticalStyle(), but only applies to the first chain.
| Parameters | |
|---|---|
int style |
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
| Parameters | |
|---|---|
int align |
setHorizontalBias
public void setHorizontalBias(float bias)
Set the horizontal bias applied to the chain
| Parameters | |
|---|---|
float bias |
from 0 to 1 |
setHorizontalGap
public void setHorizontalGap(int gap)
Set up the horizontal gap between elements
| Parameters | |
|---|---|
int gap |
setHorizontalStyle
public void setHorizontalStyle(int style)
Set horizontal chain style. Can be: Flow.CHAIN_SPREAD Flow.CHAIN_SPREAD_INSIDE Flow.CHAIN_PACKED
| Parameters | |
|---|---|
int style |
setLastHorizontalBias
public void setLastHorizontalBias(float bias)
Set the bias of the last Horizontal column.
| Parameters | |
|---|---|
float bias |
setLastHorizontalStyle
public void setLastHorizontalStyle(int style)
Set the style of the last Horizontal column.
| Parameters | |
|---|---|
int style |
Flow.CHAIN_SPREAD, Flow.CHAIN_SPREAD_INSIDE, or Flow.CHAIN_PACKED |
setLastVerticalBias
public void setLastVerticalBias(float bias)
Set the bias of the last vertical row.
| Parameters | |
|---|---|
float bias |
setLastVerticalStyle
public void setLastVerticalStyle(int style)
Set the style of the last vertical row.
| Parameters | |
|---|---|
int style |
Flow.CHAIN_SPREAD, Flow.CHAIN_SPREAD_INSIDE, or Flow.CHAIN_PACKED |
setMaxElementsWrap
public void setMaxElementsWrap(int max)
Set up the maximum number of elements before wrapping.
| Parameters | |
|---|---|
int max |
setOrientation
public void setOrientation(int orientation)
Set the orientation of the layout
| Parameters | |
|---|---|
int orientation |
either Flow.HORIZONTAL or FLow.VERTICAL |
setPadding
public void setPadding(int padding)
Set padding around the content
| Parameters | |
|---|---|
int padding |
setPaddingBottom
public void setPaddingBottom(int paddingBottom)
Set padding bottom around the content
| Parameters | |
|---|---|
int paddingBottom |
setPaddingLeft
public void setPaddingLeft(int paddingLeft)
Set padding left around the content
| Parameters | |
|---|---|
int paddingLeft |
setPaddingRight
public void setPaddingRight(int paddingRight)
Set padding right around the content
| Parameters | |
|---|---|
int paddingRight |
setPaddingTop
public void setPaddingTop(int paddingTop)
Set padding top around the content
| Parameters | |
|---|---|
int paddingTop |
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
| Parameters | |
|---|---|
int align |
setVerticalBias
public void setVerticalBias(float bias)
Set the vertical bias applied to the chain
| Parameters | |
|---|---|
float bias |
from 0 to 1 |
setVerticalGap
public void setVerticalGap(int gap)
Set up the vertical gap between elements
| Parameters | |
|---|---|
int gap |
setVerticalStyle
public void setVerticalStyle(int style)
Set vertical chain style. Can be: Flow.CHAIN_SPREAD Flow.CHAIN_SPREAD_INSIDE Flow.CHAIN_PACKED
| Parameters | |
|---|---|
int style |
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)
| Parameters | |
|---|---|
int mode |