Group

public class Group
extends View

java.lang.Object
   ↳ android.view.View
     ↳ androidx.constraintlayout.widget.Group


Control the visibility and elevation of the referenced views Added in 1.1

This class controls the visibility of a set of referenced widgets. Widgets are referenced by being added to a comma separated list of ids, e.g:

     <androidx.constraintlayout.widget.Group
              android:id="@+id/group"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:visibility="visible"
              app:constraint_referenced_ids="button4,button9" />
     
     

The visibility of the group will be applied to the referenced widgets. It's a convenient way to easily hide/show a set of widgets without having to maintain this set programmatically.

Multiple groups

Multiple groups can reference the same widgets -- in that case, the XML declaration order will define the final visibility state (the group declared last will have the last word).

Summary

Inherited constants

Fields

protected HashMap<Integer, String> mMap

Inherited fields

Public constructors

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

Public methods

void addView(View view)

Add a view to the helper.

boolean containsId(int id)
int[] getReferencedIds()

Helpers typically reference a collection of ids

int indexFromId(int id)
void loadParameters(ConstraintSet.Constraint constraint, HelperWidget child, ConstraintLayout.LayoutParams layoutParams, SparseArray<ConstraintWidget> mapIdToWidget)
void onAttachedToWindow()
int removeView(View view)

Remove a given view from the helper.

void resolveRtl(ConstraintWidget widget, boolean isRtl)
void setElevation(float elevation)
void setReferencedIds(int[] ids)

Helpers typically reference a collection of ids

void setTag(int key, Object tag)
void setVisibility(int visibility)
void updatePostConstraints(ConstraintLayout container)
void updatePreDraw(ConstraintLayout container)
void updatePreLayout(ConstraintWidgetContainer container, Helper helper, SparseArray<ConstraintWidget> map)

Protected methods

View[] getViews(ConstraintLayout layout)

Inherited methods

Fields

mMap

protected HashMap<Integer, String> mMap

Public constructors

Group

public Group (Context context)

Parameters
context Context

Group

public Group (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Group

public Group (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.

containsId

public boolean containsId (int id)

Parameters
id int

Returns
boolean

getReferencedIds

public int[] getReferencedIds ()

Helpers typically reference a collection of ids

Returns
int[] ids referenced

indexFromId

public int indexFromId (int id)

Parameters
id int

Returns
int

loadParameters

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

Parameters
constraint ConstraintSet.Constraint

child HelperWidget

layoutParams ConstraintLayout.LayoutParams

mapIdToWidget SparseArray

onAttachedToWindow

public void onAttachedToWindow ()

removeView

public int removeView (View view)

Remove a given view from the helper.

Returns
int index of view removed

resolveRtl

public void resolveRtl (ConstraintWidget widget, 
                boolean isRtl)

Parameters
widget ConstraintWidget

isRtl boolean

setElevation

public void setElevation (float elevation)

Parameters
elevation float

setReferencedIds

public void setReferencedIds (int[] ids)

Helpers typically reference a collection of ids

Parameters
ids int

Returns
void ids referenced

setTag

public void setTag (int key, 
                Object tag)

Parameters
key int

tag Object

setVisibility

public void setVisibility (int visibility)

Parameters
visibility int

updatePostConstraints

public void updatePostConstraints (ConstraintLayout container)

Parameters
container ConstraintLayout

updatePreDraw

public void updatePreDraw (ConstraintLayout container)

Parameters
container ConstraintLayout

updatePreLayout

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

Parameters
container ConstraintWidgetContainer

helper Helper

map SparseArray

Protected methods

getViews

protected View[] getViews (ConstraintLayout layout)

Parameters
layout ConstraintLayout

Returns
View[]