What is layout ?
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, as shown in figure 1.

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 .
You can declare a layout in two ways:
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.
Declaring your UI in XML allows you to separate the
presentation of your app from the code that controls its behavior.
Using XML files also makes it easy to provide different layouts
for different screen sizes and orientations (discussed further
in Supporting Different Screen Sizes).
The Android framework gives you the flexibility to use either
or both of these methods to build your app's UI. For example,
you can declare your app's default layouts in XML, and then
modify the layout at runtime.
1. LinearLayout :
Linear Layout has one goal in life:
lay out children in a single row or column
(depending on if its android:orientation is
horizontal or vertical).
2. RelativeLayout
Relative Layout is not nearly as simple as the
previous two: a look at RelativeLayout.LayoutParams
shows a large number of attributes all focused
around positioning children relative to the edges
or center of RelativeLayout (similar to FrameLayout in fact),
but also relative to one another — say, one child
layout_below another child.
3. FrameLayout
FrameLayout acts quite differently compared
to LinearLayout: here all children are drawn
as a stack — overlapping or not. The only control
on positioning is the layout_gravity attribute —
pushing the child towards a side or
centering it within the FrameLayout.
4. CoordinatorLayout
CoordinatorLayout, part of the Android Design Support
Library, is a subclass of FrameLayout and therefore
inherits its use of layout_gravity to position
children, but also includes the concept of a Behavior.
5. ConstraintLayout
ConstraintLayout is a layout on Android that gives you adaptable
and flexible ways to create views for your apps. ConstraintLayout,
which is now the default layout in Android Studio, gives you many
ways to place objects. You can constrain them to their container,
to each other or to guidelines. This allows you to create large,
complex, dynamic and responsive views in a flat hierarchy.
Mainly used layout in UI design for android application .
Thanks
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, as shown in figure 1.

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 .
You can declare a layout in two ways:
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.
Declaring your UI in XML allows you to separate the
presentation of your app from the code that controls its behavior.
Using XML files also makes it easy to provide different layouts
for different screen sizes and orientations (discussed further
in Supporting Different Screen Sizes).
The Android framework gives you the flexibility to use either
or both of these methods to build your app's UI. For example,
you can declare your app's default layouts in XML, and then
modify the layout at runtime.
1. LinearLayout :
Linear Layout has one goal in life:
lay out children in a single row or column
(depending on if its android:orientation is
horizontal or vertical).
2. RelativeLayout
Relative Layout is not nearly as simple as the
previous two: a look at RelativeLayout.LayoutParams
shows a large number of attributes all focused
around positioning children relative to the edges
or center of RelativeLayout (similar to FrameLayout in fact),
but also relative to one another — say, one child
layout_below another child.
3. FrameLayout
FrameLayout acts quite differently compared
to LinearLayout: here all children are drawn
as a stack — overlapping or not. The only control
on positioning is the layout_gravity attribute —
pushing the child towards a side or
centering it within the FrameLayout.
4. CoordinatorLayout
CoordinatorLayout, part of the Android Design Support
Library, is a subclass of FrameLayout and therefore
inherits its use of layout_gravity to position
children, but also includes the concept of a Behavior.
5. ConstraintLayout
ConstraintLayout is a layout on Android that gives you adaptable
and flexible ways to create views for your apps. ConstraintLayout,
which is now the default layout in Android Studio, gives you many
ways to place objects. You can constrain them to their container,
to each other or to guidelines. This allows you to create large,
complex, dynamic and responsive views in a flat hierarchy.
Mainly used layout in UI design for android application .
Thanks
No comments:
Post a Comment