ConstraintHelper
public abstract class ConstraintHelper extends View
Barrier |
Added in 1.1 |
Group |
Control the visibility and elevation of the referenced views Added in 1.1 |
Layer |
Layer adds the ability to move and rotate a group of views as if they were contained in a viewGroup Added in 2.0 Methods such as setRotation(float) rotate all views about a common center. |
MotionHelper |
|
VirtualLayout |
Added in 2.0 |
Carousel |
Carousel works within a MotionLayout to provide a simple recycler like pattern. |
CircularFlow |
CircularFlow virtual layout. |
Flow |
Flow VirtualLayout. |
Grid |
A helper class that helps arrange widgets in a grid form |
MotionEffect |
MotionHelper that automatically inserts keyframes for views moving in a given direction, out of: |
MotionPlaceholder |
Added in 1.1
This class manages a set of referenced widgets. HelperWidget objects can be created to act upon the set of referenced widgets. The difference between ConstraintHelper and ViewGroup is that multiple ConstraintHelper can reference the same widgets.
Widgets are referenced by being added to a comma separated list of ids, e.g.:
<androidx.constraintlayout.widget.Barrier android:id="@+id/barrier" android:layout_width="wrap_content" android:layout_height="wrap_content" app:barrierDirection="start" app:constraint_referenced_ids="button1,button2" />
Summary
Public constructors |
|---|
ConstraintHelper(Context context) |
ConstraintHelper(Context context, AttributeSet attrs) |
ConstraintHelper(Context context, AttributeSet attrs, int defStyleAttr) |
Public methods |
|
|---|---|
void |
Add a view to the helper. |
void |
hook for helpers to apply parameters in MotionLayout |
boolean |
containsId(int id)does id table contain the id |
int[] |
Helpers typically reference a collection of ids |
int |
indexFromId(int id)find the position of an id |
static boolean |
|
void |
loadParameters(Load the parameters |
void |
|
int |
removeView(View view)Remove a given view from the helper. |
void |
resolveRtl(ConstraintWidget widget, boolean isRtl)resolve the RTL |
void |
setReferencedIds(int[] ids)Helpers typically reference a collection of ids |
void |
|
void |
updatePostConstraints(ConstraintLayout container)update after constraints are resolved |
void |
updatePostLayout(ConstraintLayout container)Allows a helper a chance to update its internal object post layout or set up connections for the pointed elements |
void |
updatePostMeasure(ConstraintLayout container) |
void |
updatePreDraw(ConstraintLayout container)called before the draw |
void |
updatePreLayout(ConstraintLayout container)Allows a helper a chance to update its internal object pre layout or set up connections for the pointed elements |
void |
updatePreLayout(called before solver resolution |
void |
Allows a helper to replace the default ConstraintWidget in LayoutParams by its own subclass |
Protected methods |
|
|---|---|
void |
|
void |
applyLayoutFeatures(ConstraintLayout container) |
void |
|
View[] |
getViews(ConstraintLayout layout) |
void |
init(AttributeSet attrs) |
void |
|
void |
onMeasure(int widthMeasureSpec, int heightMeasureSpec) |
void |
|
void |
setReferenceTags(String tagList) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited methods |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Constants
Protected fields
Public constructors
ConstraintHelper
public ConstraintHelper(Context context, AttributeSet attrs, int defStyleAttr)
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.
| Parameters | |
|---|---|
View view |
applyHelperParams
public void applyHelperParams()
hook for helpers to apply parameters in MotionLayout
containsId
public boolean containsId(int id)
does id table contain the id
| Parameters | |
|---|---|
int id |
| Returns | |
|---|---|
boolean |
getReferencedIds
public int[] getReferencedIds()
Helpers typically reference a collection of ids
| Returns | |
|---|---|
int[] |
ids referenced |
indexFromId
public int indexFromId(int id)
find the position of an id
| Parameters | |
|---|---|
int id |
| Returns | |
|---|---|
int |
loadParameters
public void loadParameters(
ConstraintSet.Constraint constraint,
HelperWidget child,
ConstraintLayout.LayoutParams layoutParams,
SparseArray<ConstraintWidget> mapIdToWidget
)
Load the parameters
| Parameters | |
|---|---|
ConstraintSet.Constraint constraint |
|
HelperWidget child |
|
ConstraintLayout.LayoutParams layoutParams |
|
SparseArray<ConstraintWidget> mapIdToWidget |
removeView
public int removeView(View view)
Remove a given view from the helper.
| Parameters | |
|---|---|
View view |
| Returns | |
|---|---|
int |
index of view removed |
resolveRtl
public void resolveRtl(ConstraintWidget widget, boolean isRtl)
resolve the RTL
| Parameters | |
|---|---|
ConstraintWidget widget |
|
boolean isRtl |
setReferencedIds
public void setReferencedIds(int[] ids)
Helpers typically reference a collection of ids
updatePostConstraints
public void updatePostConstraints(ConstraintLayout container)
update after constraints are resolved
| Parameters | |
|---|---|
ConstraintLayout container |
updatePostLayout
public void updatePostLayout(ConstraintLayout container)
Allows a helper a chance to update its internal object post layout or set up connections for the pointed elements
| Parameters | |
|---|---|
ConstraintLayout container |
updatePostMeasure
public void updatePostMeasure(ConstraintLayout container)
| Parameters | |
|---|---|
ConstraintLayout container |
updatePreDraw
public void updatePreDraw(ConstraintLayout container)
called before the draw
| Parameters | |
|---|---|
ConstraintLayout container |
updatePreLayout
public void updatePreLayout(ConstraintLayout container)
Allows a helper a chance to update its internal object pre layout or set up connections for the pointed elements
| Parameters | |
|---|---|
ConstraintLayout container |
updatePreLayout
public void updatePreLayout(
ConstraintWidgetContainer container,
Helper helper,
SparseArray<ConstraintWidget> map
)
called before solver resolution
| Parameters | |
|---|---|
ConstraintWidgetContainer container |
|
Helper helper |
|
SparseArray<ConstraintWidget> map |
validateParams
public void validateParams()
Allows a helper to replace the default ConstraintWidget in LayoutParams by its own subclass
Protected methods
applyLayoutFeatures
protected void applyLayoutFeatures(ConstraintLayout container)
| Parameters | |
|---|---|
ConstraintLayout container |
applyLayoutFeaturesInConstraintSet
protected void applyLayoutFeaturesInConstraintSet(ConstraintLayout container)