Submitted By :
(Student of M.C.A 3st Sem. )
SEEMA
Constraint Layout
Constraint Layout is similar to that of other View Groups
which we have seen in Android such as Relative
Layout, Linear Layout, and many more. In this article, we will
take a look at using Constraint Layout in Android.
Attributes Description
android:id
This is used to give a unique id to the
layout.
app:layout_constraintBottom_toBottom
Of
This is used to constrain the view with
respect to the bottom position.
app:layout_constraintLeft_toLeftOf
This attribute is used to constrain the
view with respect to the left position.
app:layout_constraintRight_toRightOf
This attribute is used to constrain the
view with respect to the right position.
app:layout_constraintTop_toTopOf
This attribute is used to constrain the
view with respect to the top position
The initial Text View is constrained to its parent
(container) at top and bottom – making it centered
vertically – as well as at left and right – making it
centered horizontally
Wrap Content –It wrap 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).
In the above example we have shown the button with all properties, now look into
code level as shown below -
Advantages of using Constraint Layout
in Android
 Constraint Layout provides you the ability to completely
design your UI with the drag and drop feature provided by
the Android Studio design editor.
 It helps to improve the UI performance over other layouts.
 With the help of Constraint Layout, we can control the
group of widgets through a single line of code.
With the help of Constraint Layout, we can easily add
animations to the UI components which we used in our app.
Disadvantages of using Constraint Layout
 When we use the Constraint Layout in our app, the XML
code generated becomes a bit difficult to understand.
 In most of the cases, the result obtain will not be the
same as we got to see in the design editor.
 Sometimes we have to create a separate layout file for
handling the UI for the landscape mode.
Android ppt.pptx

Android ppt.pptx

  • 1.
    Submitted By : (Studentof M.C.A 3st Sem. ) SEEMA
  • 2.
    Constraint Layout Constraint Layoutis similar to that of other View Groups which we have seen in Android such as Relative Layout, Linear Layout, and many more. In this article, we will take a look at using Constraint Layout in Android.
  • 3.
    Attributes Description android:id This isused to give a unique id to the layout. app:layout_constraintBottom_toBottom Of This is used to constrain the view with respect to the bottom position. app:layout_constraintLeft_toLeftOf This attribute is used to constrain the view with respect to the left position. app:layout_constraintRight_toRightOf This attribute is used to constrain the view with respect to the right position. app:layout_constraintTop_toTopOf This attribute is used to constrain the view with respect to the top position
  • 4.
    The initial TextView is constrained to its parent (container) at top and bottom – making it centered vertically – as well as at left and right – making it centered horizontally
  • 5.
    Wrap Content –Itwrap 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). In the above example we have shown the button with all properties, now look into code level as shown below -
  • 6.
    Advantages of usingConstraint Layout in Android  Constraint Layout provides you the ability to completely design your UI with the drag and drop feature provided by the Android Studio design editor.  It helps to improve the UI performance over other layouts.  With the help of Constraint Layout, we can control the group of widgets through a single line of code. With the help of Constraint Layout, we can easily add animations to the UI components which we used in our app.
  • 7.
    Disadvantages of usingConstraint Layout  When we use the Constraint Layout in our app, the XML code generated becomes a bit difficult to understand.  In most of the cases, the result obtain will not be the same as we got to see in the design editor.  Sometimes we have to create a separate layout file for handling the UI for the landscape mode.