Android UI Layouts — LinearLayout — Beginner

Rey | AndroidGeek.co
2 min readApr 28, 2022

The user interface that holds the UI controls or widgets that will display on the screen of an android application or activity screen is defined by Android Layout. In general, every application is made up of a View and a ViewGroup. An android application, as we all know, has a big number of activities, and each activity may be considered one page of the app. As a result, each activity has numerous user interface components, which are View and ViewGroup instances. A hierarchy of View and ViewGroup objects is used to create all of the elements in a layout.

This article is for Android UI Layouts series articles.(Part 1)

View

A View is defined as the user interface which is used to create interactive UI components such as TextView, ImageView, EditText, RadioButton, etc., and is responsible for event handling and drawing. They are Generally Called Widgets.

ViewGroup

A ViewGroup act as a base class for layouts and layouts parameters that hold other Views or ViewGroups and to define the layout properties. They are Generally Called layouts.

Types of Android Layout

  • Android Linear Layout
  • Android Relative Layout
  • Android Constraint Layout
  • Android Frame Layout
  • Android Table Layout
  • Android Web View.
  • Android ListView
  • Android Grid View

LinearLayout in Android

The most basic layout in Android Studio is LinearLayout, which aligns all of the children sequentially either horizontally or vertically depending on the android:orientation parameter.

If you use :

android:orientation=”vertical,” items will be organized vertically.

if you use android:orientation=”horizontal,” elements will be arranged horizontally.

Some Important Attributes of LinearLayout

  • android:layout_weight
  • android:weightSum
  • android:orientation
  • android:gravity
  • android:layout_gravity
  • android:baselineAligned
  • android:id

Sample Code of LinearLayout

it’s Done :)

Please, give my repo a star and clap this article if you found it useful and I’ll be thankful if you share this article with your friends. :)

Also, you can check my video about this tutorial on YouTube :

Thank you for reading and Happy Coding!

Don’t forget 👏

--

--

I’m Reyhaneh . I’m always eager to learn new things , I like to share these things with others :) AndroidGeek Youtube : https://www.youtube.com/c/AndroidGeekco