SlideShare a Scribd company logo
Android Layout is used to define the user interface that holds the UI controls or
widgets that will appear on the screen of an android application or activity screen.
Layouts in Android are used to define the way we want a screen to be shown.
The Layout is the master plan or a blueprint of the printed/published work that
lays out the order of its various graphic elements.
Generally, every application is a combination of View and ViewGroup.
As we know, an android application contains a large number of activities and we
can say each activity is one page of the application.
So, each activity contains multiple user interface components and those
components are the instances of the View and ViewGroup.
All the elements in a layout are built using a hierarchy of View and ViewGroup
objects.
Views
A `View` is the fundamental building block of any Android UI. It represents
interactive elements like buttons, text fields, and images, serving as the user
interface’s backbone.
ViewGroups
On the other hand, a `ViewGroup` is a specialized `View` that acts as a container
for other views or view groups. It plays a pivotal role in organizing and arranging
the layout of its child views.
Types of Android Layout
Android Linear Layout: LinearLayout is a ViewGroup subclass, used to provide child
View elements one by one either in a particular direction either horizontally or
vertically based on the orientation property.
Android Relative Layout: RelativeLayout is a ViewGroup subclass, used to specify
the position of child View elements relative to each other like (A to the right of B) or
relative to the parent (fix to the top of the parent).
Android Constraint Layout: ConstraintLayout is a ViewGroup subclass, used to
specify the position of layout constraints for every child View relative to other views
present. A ConstraintLayout is similar to a RelativeLayout, but having more power.
Android Frame Layout: FrameLayout is a ViewGroup subclass, used to specify the
position of View elements it contains on the top of each other to display only a single
View inside the FrameLayout.
Android Table Layout: TableLayout is a ViewGroup subclass, used to display
the child View elements in rows and columns.
Android Web View: WebView is a browser that is used to display the web pages
in our activity layout.
Android ListView: ListView is a ViewGroup, used to display scrollable lists of
items in a single column.
Android Grid View: GridView is a ViewGroup that is used to display a scrollable
list of items in a grid view of rows and columns.
Different Attribute of the Layouts
XML attributes Description
android:id Used to specify the id of the view.
android:layout_width
Used to declare the width of View and ViewGroup elements
in the layout.
android:layout_height
Used to declare the height of View and ViewGroup elements
in the layout.
android:layout_marginL
eft
Used to declare the extra space used on the left side of View
and ViewGroup elements.
android:layout_marginR
ight
Used to declare the extra space used on the right side of View
and ViewGroup elements.
android:layout_marginT
op
Used to declare the extra space used in the top side of View
and ViewGroup elements.
android:layout_marginB
ottom
Used to declare the extra space used in the bottom side of
View and ViewGroup elements.
android:layout_gravity Used to define how child Views are positioned in the layout.
LinearLayout is the most basic layout in android studio, that aligns all the children
sequentially either in a horizontal manner or a vertical manner by specifying
the android:orientation attribute. If one applies android:orientation=”vertical” then
elements will be arranged one after another in a vertical manner and If you
apply android:orientation=”horizontal” then elements will be arranged one after
another in a horizontal manner.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
</LinearLayout>
LinearLayout- A LinearLayout aligns each of the child View in either a vertical or a
horizontal line. A vertical layout has a column of Views, whereas in a horizontal layout
there is a row of Views. It supports a weight attribute for each child View that can
control the relative size of each child View within the available space.
Attributes Description
android:layout_weight
It is defined individually to the child’s views to specify how
LinearLayout
divides the remaining space amongst the views it contains
android:weightSum Defines the total weight sum
android:orientation
How the elements should be arranged in the layout. It can be
horizontal or vertical.
android:gravity
It specifies how an object should position its content on its
X and Y axes.
Possible values are – center_vertical, fill, center, bottom,
end, etc.
android:layout_gravity
Sets the gravity of the View or Layout relative to its parent.
Possible values are – center_vertical, fill, center, bottom,
end, etc.
android:baselineAligned
This must be a boolean value, either “true” or “false” and
prevents the layout
from aligning its children’s baselines.
android:id This gives a unique id to the layout.
How to arrange children views in a vertical manner
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<!-- Add vertical in the android:orientation-->
<!-- Add Button-->
<Button
android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<!-- Add Button-->
<Button
android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<!-- Add Button-->
<Button
android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
How to arrange children views in a horizontal manner
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<!-- Add horizontal in the android:orientation-->
<!-- Add Button-->
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dp" />
<!-- Add Button-->
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dp" />
<!-- Add Button-->
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dp" />
</LinearLayout>
How to use layout_weight and weightSum
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3"
tools:context=".MainActivity">
<!-- Add value in the android:weightSum-->
<!-- Add horizontal in the android:orientation-->
<!-- Add Button-->
<!-- Add value in the android:layout_weight-->
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1" />
<!-- Add Button-->
<!-- Add value in the android:layout_weight-->
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1" />
<!-- Add Button-->
<!-- Add value in the android:layout_weight-->
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1" />
</LinearLayout>
4. How to use gravity
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3"
tools:context=".MainActivity">
<!-- Add value in the android:weightSum-->
<!-- Add horizontal in the android:orientation-->
<!-- Add Button-->
<!-- Add value in the android:gravity -->
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="bottom|center"
android:text="GFG" />
<!-- Add Button-->
<!-- Add value in the android:gravity -->
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="center"
android:text="GFG" />
<!-- Add Button-->
<!-- Add value in the android:gravity -->
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="center|top"
android:text="GFG" />
</LinearLayout>
How to use layout_gravity
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<!-- Add vertical in the android:orientation-->
<!-- Add Button-->
<!-- Add value in the layout_gravity -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp" />
<!-- Add Button-->
<!-- Add value in the layout_gravity -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_margin="10dp" />
<!-- Add Button-->
<!-- Add value in the layout_gravity -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_margin="10dp" />
</LinearLayout>

More Related Content

PPTX
Android Layout.pptx
PPTX
UNIT5newpart2pptx__2024_11_13_09_52_11 (1).pptx
PPTX
Android development session 3 - layout
PPTX
WMP_MP02_revd_03(10092023).pptx
PDF
01 08 - graphical user interface - layouts
PPT
android layouts
PPTX
WMP_MP02_revd(10092023).pptx
PPTX
行動App開發管理實務unit3
Android Layout.pptx
UNIT5newpart2pptx__2024_11_13_09_52_11 (1).pptx
Android development session 3 - layout
WMP_MP02_revd_03(10092023).pptx
01 08 - graphical user interface - layouts
android layouts
WMP_MP02_revd(10092023).pptx
行動App開發管理實務unit3

Similar to INTRODUCTION AND BASICS OF Android NOTES.pptx (20)

PPT
View groups containers
PPTX
Unit 2 part for information technology1 4.pptx
PDF
04 user interfaces
PDF
Chapter 5 - Layouts
DOCX
Android practice of layout in application-chapter6
PPTX
mobile application development -unit-3-
PDF
Basic Android Layout
PDF
Mobile Application Development -Lecture 07 & 08.pdf
PPT
Android UI
PPT
Android Ui
PDF
Android UI Fundamentals part 1
PDF
How to use data binding in android
PPTX
Android Training (Android UI)
PDF
Android ui layout
PPT
Beginning Native Android Apps
PPTX
Building a simple user interface lesson2
PPTX
4.pptx
ODP
Android training day 2
DOCX
How to create ui using droid draw
View groups containers
Unit 2 part for information technology1 4.pptx
04 user interfaces
Chapter 5 - Layouts
Android practice of layout in application-chapter6
mobile application development -unit-3-
Basic Android Layout
Mobile Application Development -Lecture 07 & 08.pdf
Android UI
Android Ui
Android UI Fundamentals part 1
How to use data binding in android
Android Training (Android UI)
Android ui layout
Beginning Native Android Apps
Building a simple user interface lesson2
4.pptx
Android training day 2
How to create ui using droid draw
Ad

More from Poornima E.G. (10)

PPT
Introduction to Pattern Recognition NOTES.ppt
PPTX
Android Application managing activites.pptx
PDF
ROUND4GuestFacultyAllotmentList,Noworkloadcandidates.pdf
PDF
GUI.pdf
DOCX
VTU MCA 2022 JAVA Exceeption Handling.docx
PPT
Process and Thread
PPT
Operating System basics Introduction
PPTX
csharp_dotnet_adnanreza.pptx
PDF
Millimeter wave mobile communications for 5 g Cellular
PDF
Semantic open io t service platform technology
Introduction to Pattern Recognition NOTES.ppt
Android Application managing activites.pptx
ROUND4GuestFacultyAllotmentList,Noworkloadcandidates.pdf
GUI.pdf
VTU MCA 2022 JAVA Exceeption Handling.docx
Process and Thread
Operating System basics Introduction
csharp_dotnet_adnanreza.pptx
Millimeter wave mobile communications for 5 g Cellular
Semantic open io t service platform technology
Ad

Recently uploaded (20)

PDF
Basic Mud Logging Guide for educational purpose
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Insiders guide to clinical Medicine.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Cell Types and Its function , kingdom of life
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
01-Introduction-to-Information-Management.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
Basic Mud Logging Guide for educational purpose
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Insiders guide to clinical Medicine.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Cell Types and Its function , kingdom of life
Abdominal Access Techniques with Prof. Dr. R K Mishra
102 student loan defaulters named and shamed – Is someone you know on the list?
Microbial diseases, their pathogenesis and prophylaxis
01-Introduction-to-Information-Management.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
VCE English Exam - Section C Student Revision Booklet
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Complications of Minimal Access Surgery at WLH
O5-L3 Freight Transport Ops (International) V1.pdf

INTRODUCTION AND BASICS OF Android NOTES.pptx

  • 1. Android Layout is used to define the user interface that holds the UI controls or widgets that will appear on the screen of an android application or activity screen. Layouts in Android are used to define the way we want a screen to be shown. The Layout is the master plan or a blueprint of the printed/published work that lays out the order of its various graphic elements. Generally, every application is a combination of View and ViewGroup. As we know, an android application contains a large number of activities and we can say each activity is one page of the application. So, each activity contains multiple user interface components and those components are the instances of the View and ViewGroup. All the elements in a layout are built using a hierarchy of View and ViewGroup objects.
  • 2. Views A `View` is the fundamental building block of any Android UI. It represents interactive elements like buttons, text fields, and images, serving as the user interface’s backbone. ViewGroups On the other hand, a `ViewGroup` is a specialized `View` that acts as a container for other views or view groups. It plays a pivotal role in organizing and arranging the layout of its child views.
  • 3. Types of Android Layout Android Linear Layout: LinearLayout is a ViewGroup subclass, used to provide child View elements one by one either in a particular direction either horizontally or vertically based on the orientation property. Android Relative Layout: RelativeLayout is a ViewGroup subclass, used to specify the position of child View elements relative to each other like (A to the right of B) or relative to the parent (fix to the top of the parent). Android Constraint Layout: ConstraintLayout is a ViewGroup subclass, used to specify the position of layout constraints for every child View relative to other views present. A ConstraintLayout is similar to a RelativeLayout, but having more power. Android Frame Layout: FrameLayout is a ViewGroup subclass, used to specify the position of View elements it contains on the top of each other to display only a single View inside the FrameLayout.
  • 4. Android Table Layout: TableLayout is a ViewGroup subclass, used to display the child View elements in rows and columns. Android Web View: WebView is a browser that is used to display the web pages in our activity layout. Android ListView: ListView is a ViewGroup, used to display scrollable lists of items in a single column. Android Grid View: GridView is a ViewGroup that is used to display a scrollable list of items in a grid view of rows and columns.
  • 5. Different Attribute of the Layouts XML attributes Description android:id Used to specify the id of the view. android:layout_width Used to declare the width of View and ViewGroup elements in the layout. android:layout_height Used to declare the height of View and ViewGroup elements in the layout. android:layout_marginL eft Used to declare the extra space used on the left side of View and ViewGroup elements. android:layout_marginR ight Used to declare the extra space used on the right side of View and ViewGroup elements. android:layout_marginT op Used to declare the extra space used in the top side of View and ViewGroup elements. android:layout_marginB ottom Used to declare the extra space used in the bottom side of View and ViewGroup elements. android:layout_gravity Used to define how child Views are positioned in the layout.
  • 6. LinearLayout is the most basic layout in android studio, that aligns all the children sequentially either in a horizontal manner or a vertical manner by specifying the android:orientation attribute. If one applies android:orientation=”vertical” then elements will be arranged one after another in a vertical manner and If you apply android:orientation=”horizontal” then elements will be arranged one after another in a horizontal manner. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> </LinearLayout>
  • 7. LinearLayout- A LinearLayout aligns each of the child View in either a vertical or a horizontal line. A vertical layout has a column of Views, whereas in a horizontal layout there is a row of Views. It supports a weight attribute for each child View that can control the relative size of each child View within the available space.
  • 8. Attributes Description android:layout_weight It is defined individually to the child’s views to specify how LinearLayout divides the remaining space amongst the views it contains android:weightSum Defines the total weight sum android:orientation How the elements should be arranged in the layout. It can be horizontal or vertical. android:gravity It specifies how an object should position its content on its X and Y axes. Possible values are – center_vertical, fill, center, bottom, end, etc. android:layout_gravity Sets the gravity of the View or Layout relative to its parent. Possible values are – center_vertical, fill, center, bottom, end, etc. android:baselineAligned This must be a boolean value, either “true” or “false” and prevents the layout from aligning its children’s baselines. android:id This gives a unique id to the layout.
  • 9. How to arrange children views in a vertical manner <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <!-- Add vertical in the android:orientation--> <!-- Add Button--> <Button android:layout_width="match_parent" android:layout_margin="10dp" android:layout_height="wrap_content"/>
  • 10. <!-- Add Button--> <Button android:layout_width="match_parent" android:layout_margin="10dp" android:layout_height="wrap_content"/> <!-- Add Button--> <Button android:layout_width="match_parent" android:layout_margin="10dp" android:layout_height="wrap_content"/> </LinearLayout>
  • 11. How to arrange children views in a horizontal manner <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" tools:context=".MainActivity"> <!-- Add horizontal in the android:orientation--> <!-- Add Button--> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_margin="10dp" />
  • 12. <!-- Add Button--> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_margin="10dp" /> <!-- Add Button--> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_margin="10dp" /> </LinearLayout>
  • 13. How to use layout_weight and weightSum <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:weightSum="3" tools:context=".MainActivity"> <!-- Add value in the android:weightSum--> <!-- Add horizontal in the android:orientation--> <!-- Add Button--> <!-- Add value in the android:layout_weight--> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="1" />
  • 14. <!-- Add Button--> <!-- Add value in the android:layout_weight--> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="1" /> <!-- Add Button--> <!-- Add value in the android:layout_weight--> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="1" /> </LinearLayout>
  • 15. 4. How to use gravity <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:weightSum="3" tools:context=".MainActivity"> <!-- Add value in the android:weightSum--> <!-- Add horizontal in the android:orientation--> <!-- Add Button--> <!-- Add value in the android:gravity --> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_margin="10dp"
  • 16. android:layout_weight="1" android:gravity="bottom|center" android:text="GFG" /> <!-- Add Button--> <!-- Add value in the android:gravity --> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="1" android:gravity="center" android:text="GFG" /> <!-- Add Button--> <!-- Add value in the android:gravity --> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_weight="1" android:gravity="center|top" android:text="GFG" /> </LinearLayout>
  • 17. How to use layout_gravity <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <!-- Add vertical in the android:orientation--> <!-- Add Button--> <!-- Add value in the layout_gravity -->
  • 18. <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_margin="10dp" /> <!-- Add Button--> <!-- Add value in the layout_gravity --> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:layout_margin="10dp" /> <!-- Add Button--> <!-- Add value in the layout_gravity --> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_margin="10dp" /> </LinearLayout>