Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
132 views

Android Constraint Layout

ConstraintLayout allows for complex layouts with a flat view hierarchy unlike RelativeLayout. It uses constraints between views and the parent layout to position views, where each view needs at least one horizontal and vertical constraint. To use ConstraintLayout, add the repository to build.gradle and include the ConstraintLayout dependency.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views

Android Constraint Layout

ConstraintLayout allows for complex layouts with a flat view hierarchy unlike RelativeLayout. It uses constraints between views and the parent layout to position views, where each view needs at least one horizontal and vertical constraint. To use ConstraintLayout, add the repository to build.gradle and include the ConstraintLayout dependency.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

You might also like