Lay Out
Lay Out
Lay Out
Layouts
• A layout defines the structure for a user interface in your
app, such as in an activity.
• All elements in the layout are built using a hierarchy of
View and ViewGroup objects.
• A View usually draws something the user can see and
interact with. Whereas a ViewGroup is an invisible
container that defines the layout structure for View and
other ViewGroup objects
• The View objects are usually called "widgets" and can be
one of many subclasses, such as Button or TextView.
• The ViewGroup objects are usually called "layouts" can
be one of many types that provide a different layout
structure, such as LinearLayout or ConstraintLayout .
Layouts
• Declare UI elements in XML. Android provides
a straightforward XML vocabulary that
corresponds to the View classes and
subclasses, such as those for widgets and
layouts. You can also use Android Studio's
Layout Editor to build your XML layout using a
drag-and-drop interface.
• Instantiate layout elements at runtime. Your
app can create View and ViewGroup objects
(and manipulate their properties)
programmatically.
Android Layout Attributes
• GridLayout : GridLayout
uses a grid of infinitely-
thin lines to separate its
drawing area into: rows,
columns, and cells. It
supports both row and
column spanning, this
means it is possible to
merge adjacent cells into
a large cell (a rectangle)
to contain a View.
Layouts Displays a scrolling single column list.
• Android ListView is a
view which groups
several items and
display them in
vertical scrollable list.
The list items are
automatically inserted
to the list using an
Adapter that pulls
content from a source
such as an array or
database.
Layouts Displays web pages.
• ViewGroup
• The ViewGroup class is a subclass of the View class.
ViewGroup instances work as containers for View instances to
group View instances together. Android contains the
following commonly used ViewGroup subclasses:
• LinearLayout
• RelativeLayout
• ListView
• GridView