What is the layout & how many layouts are available in Android

What is Layout?


The android layout is used to define the user interface which holds the different UI controls that will appear on the screen. Any application has one or more activities and we say the activity is one page of the application. Each activity contains interface components and those components are the instances of the View and ViewGroup.

Types of Android Layout:-

1. Linear Layout:– It provides child view elements one by one in a particular direction. That means you can set your child view elements either horizontally or vertically based on the orientation property.

2. Relative Layout:- It specifies the position of child view elements relative to each other like or relative to the parent. For example, we have Button A and we need to set that button to the right of Button B then at that time we need this layout.

3. Constraint Layout:- It specifies the position of layout constraints for every child view relative to other views present. It is similar to a Relative Layout, but it having more power.

4. Table Layout:- It displays the child view elements in rows and columns.

Table Layout android

5. Frame Layout:- It specifies the position of View elements it contains on the top of each other to display only a single View inside the FrameLayout.

frameLayout android

6. Web View:- It displays the web pages in our activity layout or also we say it works like a web browser.

webview android

7. List View:- It is a ViewGroup, used to display a scrollable list of items in a single column.

8. Grid View:- It is a ViewGroup that is used to display a scrollable list of items in the grid view of rows and columns.

I give you the example of Linear Layout so you can batter understand the code. So when you want to create any other layout then you can easily do it. so let’s see…..

So that is how we create our layout in android.


0 Comments