In this Tutorial, we will understand the layouts present in android studio.
Types of Layouts
- Linear Layout
- Relative Layout
- Constraint Layout
- Frame Layout
- Table Layout
- Constraint layout
These layouts have constraints where constraints gives freedom to adjust your widget according to your device size.
On other hand other layouts such as linear or relative doesn’t comes up with the customization
To understand the concept of constraints lets create a button to understand the example
To Create button in constraint layout by writing below code
To add Constraints in layout use the below code in layout.xml
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"
No matter what your device screen size is,the button will auto fits and aligned in center
These layouts are specific to to orientation. all the widgets or Childs are align in to a single direction vertically or horizontally.
These layouts are often used by android designer’s but due to its drawback now days constraints are the best layouts so far
Example of linear layout
Here we are not able to move our button in center as we are using linear layout ,either we can add multiple buttons vertically or horizontally
All layout elements inside RelativeLayout are relative, not in line with LinearLayout
Arranges elements relative to parent or other elements
Create a button next to image view and add a text view below that ,this can be done by relative layout
In Relative layout you need to add margins and alignment to make it support to other device apart from you are making for.
Frame layouts are frame specific layouts. these layouts are used when user want Childs in a specific frame all the Childs use the same frame
These layouts are used to create tables in your android app,
<Table row are used to define rows and columns
Thanks for read……….