ANDROID CONSTRAINT LAYOUT
ConstraintLayout allows you to create large and complex layouts with a flat view
hierarchy (no nested view groups). It’s similar to RelativeLayout in that all views
are layed 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.
Constraints overview
To define a view's position in ConstraintLayout, you must add at least one
horizontal and one vertical constraint for the view. Each constraint represents a
connection or alignment to another view, the parent layout, or an invisible
guideline. Each constraint defines the view's position along either the vertical or
horizontal axis; so each view must have a minimum of one constraint for each axis,
but often more are necessary.
To use ConstraintLayout in your project, proceed as follows:
1. Ensure you have the maven.google.com repository declared in your module-
level build.gradle file:
repositories {
maven {
url 'https://maven.google.com'
}
}
2. Add the library as a dependency in the same build.gradle file:
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
3. In the toolbar or sync notification, click Sync Project with Gradle Files.