public class Flow extends VirtualLayout


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
As VirtualLayouts are ConstraintHelpers, 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, 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
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.

Summary

Constants

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

Public constructors

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

Public methods

void
loadParameters(
    ConstraintSet.Constraint constraint,
    HelperWidget child,
    ConstraintLayout.LayoutParams layoutParams,
    SparseArray<ConstraintWidget> mapIdToWidget
)
void
onMeasure(
    VirtualLayout layout,
    int widthMeasureSpec,
    int heightMeasureSpec
)
void
resolveRtl(ConstraintWidget widget, boolean isRtl)
void

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

void

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

void

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

void

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

Set up the horizontal gap between elements

void
setHorizontalStyle(int style)

Set horizontal chain style.

void

Set the bias of the last Horizontal column.

void

Set the style of the last Horizontal column.

void
setLastVerticalBias(float bias)

Set the bias of the last vertical row.

void

Set the style of the last vertical row.

void

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
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Inherited Constants

From androidx.constraintlayout.widget.ConstraintHelper
static final String
CHILD_TAG = "CONSTRAINT_LAYOUT_HELPER_CHILD"
From android.view.View
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final int
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
static final String
static final String
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int
GONE = 8
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
KEEP_SCREEN_ON = 67108864
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
NO_ID = -1
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final float
static final float
static final float
static final float
static final float
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final String
VIEW_LOG_TAG = "View"
static final int
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>

Inherited methods

From androidx.constraintlayout.widget.ConstraintHelper
void
addView(View view)

Add a view to the helper.

void

hook for helpers to apply parameters in MotionLayout

void
void
boolean
containsId(int id)

does id table contain the id

int[]

Helpers typically reference a collection of ids

View[]
int
indexFromId(int id)

find the position of an id

static boolean
void
int

Remove a given view from the helper.

void
setIds(String idList)
void
void
setReferencedIds(int[] ids)

Helpers typically reference a collection of ids

void
setTag(int key, Object tag)
void

update after constraints are resolved

void

Allows a helper a chance to update its internal object post layout or set up connections for the pointed elements

void
void

called before the draw

void

Allows a helper a chance to update its internal object pre layout or set up connections for the pointed elements

void
updatePreLayout(
    ConstraintWidgetContainer container,
    Helper helper,
    SparseArray<ConstraintWidget> map
)

called before solver resolution

void

Allows a helper to replace the default ConstraintWidget in LayoutParams by its own subclass

From android.view.View
void
void
addExtraDataToAccessibilityNodeInfo(
    AccessibilityNodeInfo info,
    String extraDataKey,
    Bundle arguments
)
void
addFocusables(ArrayList<View> views, int direction)
void
void
void
void
void
ViewPropertyAnimator
void

This method is deprecated.

void
boolean
void
void

This method is deprecated.

void
boolean
boolean
boolean
boolean
boolean
canScrollHorizontally(int direction)
boolean
canScrollVertically(int direction)
final void
void
final void