Android Codingprogrammingtechnology

Android Coding: Constraint Layout

A Constraint Layout is a ViewGroup layout on Android that gives you adaptable and flexible ways to create views for your apps. It is an advanced version of a Relative layout. This layout is used to reduce the child view hierarchies and improve performance.

A Constraint Layout is an android.view.ViewGroup which allows you to position and size widgets in a flexible way.

It is also the default layout in Android Studio, and gives you many ways to place objects. You can constrain the objects to their container, to each other, or to guidelines. This allows you to create large, complex layouts, dynamic and responsive views in a flat hierarchy. It even supports animations!

Properties

  • Wrap Content –It wraps the view size according to data
  • Any Size – This is very similar to match parent.
  • Fixed Size – This allows standard height and width (fixed sizes)

Advantages of Constraint Layout over Other Layouts

  1. One great advantage of the constraint layout is that you can perform animations on your layout views with very little code.
  2. You can build your complete layout with simple drag-and-drop on the Android Studio design editor.
  3. You can control what happens to a group of widgets through a single line of code.
  4. This ViewGroup improve performance over other layouts.

Note: Constraint Layout is available as a support library that can be used on Android systems starting with API level 9 (Gingerbread). 

 

What's your reaction?

Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0

Leave a reply

Your email address will not be published. Required fields are marked *

Next Article:

0 %