Layouts in Android

In this tutorial you will learn about different layouts in android.

Android layouts are used to define the visual structure of user interface. The UI components like label, button, textbox, etc. are defined inside a layout. So before designing UI for an android application you must know about different layouts available in android.

There are two ways to design UI in android.

  • Using XML file
  • Using Java code at run time

Designing layout using XML file is better because the presentation of the app is kept separate from the code that controls the behavior. By doing this the debugging and alteration in UI becomes easier. The layout XML files are placed inside res/layout folder.

Types of Layouts in Android

The various layouts that are available in android are given below. Here I am giving a brief introduction of each layout. I will explain them in detail with example in upcoming tutorials.

Linear Layout

As its name indicates, Linear Layout is used to arrange its children in linear manner, either vertically or horizontally.

linear layout

Relative Layout

This layout is used to place child views relative to each other. We can specify the position of each view or layout relative to sibling or parent.

relative layout

Table Layout

This layout is used to arrange the child views into rows and columns.
table layout

Absolute Layout

Absolute Layout is used to specify the exact locations of its children in x and y coordinates.

absolute layout

Frame Layout

This layout is designed to block out an area on the screen to display a single view.

 

Tab Layout

It provides a horizontal layout to display tabs.

tab layout

List View

It is used to display a list of vertically scrollable items.

list view

Grid View

It is used to display items in two-dimensional scrolling grid.

grid layout

If you found any mistake or have doubts regarding above layouts in android tutorial then feel free to mention it by commenting below.

Leave a Reply

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