Versions

[{“Name”:“2.3”,“GroupName”:null},{“Name”:“2.3.3”,“GroupName”:null},{“Name”:“3.0.x”,“GroupName”:null},{“Name”:“3.1.x”,“GroupName”:null},{“Name”:“3.2.x”,“GroupName”:null},{“Name”:“4.0”,“GroupName”:null},{“Name”:“4.0.3”,“GroupName”:null},{“Name”:“4.1”,“GroupName”:null},{“Name”:“4.2”,“GroupName”:null},{“Name”:“4.3”,“GroupName”:null},{“Name”:“4.4”,“GroupName”:null},{“Name”:“4.4W”,“GroupName”:null},{“Name”:“5.0”,“GroupName”:null},{“Name”:“5.1”,“GroupName”:null},{“Name”:“6.0”,“GroupName”:null},{“Name”:“7.0”,“GroupName”:null},{“Name”:“7.1”,“GroupName”:null}]

Introduction

ConstraintLayout is a ViewGroup which allows you to position and size widgets in a flexible way. It is compatible with Android 2.3 (API level 9) and higher.

It allows you to create large and complex layouts with a flat view hierarchy. It is similar to RelativeLayout in that all views are laid out according to relationships between sibling views and the parent layout, but it’s more flexible than RelativeLayout and easier to use with Android Studio’s Layout Editor.

Syntax

- public void addView(View child, int index, ViewGroup.LayoutParams params)
- public ConstraintLayout.LayoutParams generateLayoutParams(AttributeSet attrs)
- public void onViewAdded(View view)
- public void onViewRemoved(View view)
- public void removeView(View view)
- public void requestLayout()

- protected boolean checkLayoutParams(ViewGroup.LayoutParams params)
- protected ConstraintLayout.LayoutParams generateDefaultLayoutParams()
- protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams params)
- protected void onLayout(boolean changed, int left, int top, int right, int bottom)
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
- public void resolveLayoutDirection(int layoutDirection)
- public void validate()

- protected void setBaseAttributes(TypedArray a, int widthAttr, int heightAttr)

Parameters

Parameter | Details | ——— | —–– | child | The View to be added to the layout | index | The index of the View in the layout hierarchy | params | The LayoutParams of the View | attrs | The AttributeSet that defines the LayoutParams | view | The View that has been added or removed | changed | Indicates if this View has changed size or position | left | The left position, relative to the parent View | top | The top position, relative to the parent View | right | The right position, relative to the parent View | bottom | The bottom position, relative to the parent View | widthMeasureSpec | The horizontal space requirements imposed by the parent View | heightMeasureSpec | The vertical space requirements imposed by the parent View | layoutDirection | - | a | - | widthAttr | - | heightAttr | - |

Remarks

At Google IO 2016 Google announced a new Android layout named ConstraintLayout.

Pay attention because currently, this layout is a Beta release.

Fore More About Constraint Layout:

**https://codelabs.developers.google.com/codelabs/constraint-layout/index.html**