The layout is part of the AndroidJetpack. In android, we usually used an XML based layout.

An XML based layout provides a structure for the user interface in the application. The elements in the layout are using a hierarchy of

graphical representation of the view of hierarchy, define a Layout

Note: image reference from

Layout Declaration:
In 2-ways we can declare a layout

  1. Initialize the layout at runtime: We can also initialize a layout programmatically in our application.

Write XML:


here’s, in an XML layout uses a vertical

layouts in the XML file save as

Load XML:

For example

Common Layout:

  • Linear Layout:
Horizontal Linear Layout View
Vertical Linear Layout View
Relative Layout View

Web View:

WebView representation

Other Layouts:

  • ListView:
Listview representation
  • GridView:
GridView representation

Quick Recap:

  • The elements in the layout are using a hierarchy of View and ViewGroup objects.
  • 2-ways we can declare a layout.
  • The layout has only one root or parent element in each layout.
  • In activity.onCreate() callback method you load your layout XML file with setContentView(), and passing the layout resource in the form of R.layout.layout_file_name as a reference.

You can also see:

Android Emulator

Activity-Lifecycle in Android

Hi everyone, myself Golap an Android app developer with UI/UX designer.