Android Studio:- Layouts and Views

Hello everyone welcome to KnowledgeSuttra . Today we are learning about Layouts in Android. In last Blog we have build our first Application with Android. Form that blog we get idea about working of Android studio and some of its feature. Now you can Handel Android studio easily.  Today we are learn about the Layouts which are play very important roll in Android Applications. To build any Application we need an Layout, there are different types of layouts present. According to our requirement we can use them.

Let’s take one example of an Application, whatsApp is using linear Layout of type vertical integrate with List View.

Just like that every Application need one Layout which defines the structure for a user interface in your Application, means how it look just like Displays a scrolling single column list, Displays a scrolling grid of columns and rows, etc. first step of Building any application is that you have to select layout for Application.

Types of layouts

The most common type of layouts are:

  • Linear Layout
  • Relative Layout
  • Constraint Layout

There are some other layouts  such as:

  • Web View Layout
  • Frame Layout
  • List View Layout
  • Grid View Layout
  • Table Layout
  • Space Layout

All this are types of layouts and each layout does a unique work and we can marge two or more Layout in one Activity according to our requirements.

Linear Layout

A layout which arranges other attributes (views) in a sequential manner that layout is called Linear layout. It is having two types.

  • Horizontal Linear layout
  • Vertical Linear layoutandroid studio:  linear layout

Sample code for Linear Layout

<LinearLayout xmlns:android=””








Relative Layout

Relative Layout is a view which gathers that presentations child views in relative positions. The situation of each view can be determined as with respect to kin components, (for example, to one side of or underneath another view) or in positions relation to the parent Relative Layout territory, (for example, adjusted to the base, left or focus).

Sample code for Relative layout with some attributes

<RelativeLayout xmlns:android=””
android:paddingRight=”16dp” >
android:hint=”@string/reminder” />     <Button
android:text=”@string/done” />


 Constraint Layout

It is new layout which is use to make Application for any size of Android phone. It can adjust according to the size of phone or android system. It support library that you can use on Android systems starting with API level 9 and higher.

There are different kinds of constraints that we can use:

  • Relative positioning
  • Centering positioning
  • Circular positioning
  • Dimension constraints
  • Margins
  • Optimizer

Other layouts are use inside this three layouts or marge with these layouts depending on the problem statement.

Well here i quoted quick guide on Layouts and Views. If you have any query feel free to ask me

Sharing is caring!

Leave a Reply