First Displace Constraintlayout

Posted on

ConstraintLayout allows yous to exercise large as well as complex layouts alongside a apartment stance hierarchy (no nested stance groups). It’s like to RelativeLayout inward that all views are layed out according to relationships betwixt sibling views as well as the nurture layout, simply it’s to a greater extent than flexible than RelativeLayout as well as easier to piece of occupation alongside Android Studio’s Layout Editor.

To use ConstraintLayout, brand certain to install Support Repository of ConstraintLayout for Android as well as Solver for ConstraintLayout in Android SDK Manager:

Add dependency of ConstraintLayout library inward your module-level build.gradle file:

 dependencies {     compile '' }  

In the toolbar or sync notification, click Sync Project alongside Gradle Files.

We tin convert an existing layout to a constraint layout inward Android Studio’s Layout Editor:
– Open your layout inward Android Studio as well as click the Design tab at the bottom of the editor window.
– In the Component Tree window, right-click the layout as well as click Convert layout to ConstraintLayout.

After finished, the helloworld default layout converted to:

<?xml version="1.0" encoding="utf-8"?> < xmlns:android=""     xmlns:app=""     xmlns:tools=""     android:id="@+id/activity_main"     android:layout_width="match_parent"     android:layout_height="match_parent"     tools:context="com.blogspot.android_er.androidconstraintlayout.MainActivity">      <TextView         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="Hello World!"         tools:layout_constraintTop_creator="1"         android:layout_marginStart="16dp"         android:layout_marginTop="16dp"         tools:layout_constraintLeft_creator="1"         app:layout_constraintLeft_toLeftOf="parent"         app:layout_constraintTop_toTopOf="parent" /> </> 

This video exhibit howto, step-by-step:

Build a Responsive UI alongside ConstraintLayout

Building interfaces alongside ConstraintLayout inward Android Studio