Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

Layer

public class Layer
extends View

java.lang.Object
   ↳ View
     ↳ androidx.constraintlayout.helper.widget.Layer


Added in 2.0

Summary

Fields

protected float mComputedCenterX

protected float mComputedCenterY

protected float mComputedMaxX

protected float mComputedMaxY

protected float mComputedMinX

protected float mComputedMinY

Public constructors

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

Public methods

void addView(View view)

Add a view to the helper.

int[] getReferencedIds()

Helpers typically reference a collection of ids

void loadParameters(ConstraintSet.Constraint constraint, HelperWidget child, ConstraintLayout.LayoutParams layoutParams, mapIdToWidget)
void removeView(View view)

Remove a given view from the helper.

void resolveRtl(ConstraintWidget widget, boolean isRtl)
void setPivotX(float pivotX)

Sets the pivot point for scale operations.

void setPivotY(float pivotY)

Sets the pivot point for scale operations.

void setReferencedIds(int[] ids)

Helpers typically reference a collection of ids

void setRotation(float angle)

Rotates all associated views around a single point post layout..

void setScaleX(float scaleX)

Scales all associated views around a single point post layout..

void setScaleY(float scaleY)

Scales all associated views around a single point post layout..

void setTranslationX(float dx)

Shift all the views in the X direction post layout.

void setTranslationY(float dy)

Shift all the views in the Y direction post layout.

void updatePostConstraints(ConstraintLayout constainer)
void updatePreLayout(ConstraintWidgetContainer container, Helper helper, map)

Protected methods

void calcCenters()
View[] getViews(ConstraintLayout layout)
void onAttachedToWindow()

Inherited methods

Fields

mComputedCenterX

protected float mComputedCenterX

mComputedCenterY

protected float mComputedCenterY

mComputedMaxX

protected float mComputedMaxX

mComputedMaxY

protected float mComputedMaxY

mComputedMinX

protected float mComputedMinX

mComputedMinY

protected float mComputedMinY

Public constructors

Layer

public Layer (Context context)

Parameters
context Context

Layer

public Layer (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Layer

public Layer (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

addView

public void addView (View view)

Add a view to the helper. The referenced view need to be a child of the helper's parent. The view also need to have its id set in order to be added.

getReferencedIds

public int[] getReferencedIds ()

Helpers typically reference a collection of ids

Returns
int[] ids referenced

loadParameters

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

Parameters
constraint ConstraintSet.Constraint

child HelperWidget

layoutParams ConstraintLayout.LayoutParams

mapIdToWidget

removeView

public void removeView (View view)

Remove a given view from the helper.

resolveRtl

public void resolveRtl (ConstraintWidget widget, 
                boolean isRtl)

Parameters
widget ConstraintWidget

isRtl boolean

setPivotX

public void setPivotX (float pivotX)

Sets the pivot point for scale operations. Setting it to Float.NaN (default) results in the center of the group being used.

Parameters
pivotX float: The X location of the pivot point

setPivotY

public void setPivotY (float pivotY)

Sets the pivot point for scale operations. Setting it to Float.NaN (default) results in the center of the group being used.

Parameters
pivotY float: The Y location of the pivot point

setReferencedIds

public void setReferencedIds (int[] ids)

Helpers typically reference a collection of ids

Parameters
ids int

Returns
void ids referenced

setRotation

public void setRotation (float angle)

Rotates all associated views around a single point post layout.. The point is the middle of the bounding box or set by setPivotX,setPivotX;

setScaleX

public void setScaleX (float scaleX)

Scales all associated views around a single point post layout.. The point is the middle of the bounding box or set by setPivotX,setPivotX;

Parameters
scaleX float: The value to scale in X.

setScaleY

public void setScaleY (float scaleY)

Scales all associated views around a single point post layout.. The point is the middle of the bounding box or set by setPivotX,setPivotX;

Parameters
scaleY float: The value to scale in X.

setTranslationX

public void setTranslationX (float dx)

Shift all the views in the X direction post layout.

Parameters
dx float: number of pixes to shift

setTranslationY

public void setTranslationY (float dy)

Shift all the views in the Y direction post layout.

Parameters
dy float: number of pixes to shift

updatePostConstraints

public void updatePostConstraints (ConstraintLayout constainer)

Parameters
constainer ConstraintLayout

updatePreLayout

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

Parameters
container ConstraintWidgetContainer

helper Helper

map

Protected methods

calcCenters

protected void calcCenters ()

getViews

protected View[] getViews (ConstraintLayout layout)

Parameters
layout ConstraintLayout

Returns
View[]

onAttachedToWindow

protected void onAttachedToWindow ()