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.
As its name indicates, Linear Layout is used to arrange its children in linear manner, either vertically or horizontally.
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.
This layout is used to arrange the child views into rows and columns.
Absolute Layout is used to specify the exact locations of its children in x and y coordinates.
This layout is designed to block out an area on the screen to display a single view.
It provides a horizontal layout to display tabs.
It is used to display a list of vertically scrollable items.
It is used to display items in two-dimensional scrolling grid.
If you found any mistake or have doubts regarding above layouts in android tutorial then feel free to mention it by commenting below.