Module - III Android UID Essentials
Module - III Android UID Essentials
ESSENTIALS
Module - III
Android UI Layouts
The basic building block for user interface is
a View object which is created from the View class
and occupies a rectangular area on the screen and is
responsible for drawing and event handling.
View is the base class for widgets, which are used
to create interactive UI components like buttons,
text fields, etc.
The ViewGroup is a subclass of View and
provides invisible container that hold other Views
or other ViewGroups and define their layout
properties.
UI Input Controls
A View is an object that draws something on the
screen that the user can interact with and
a ViewGroup is an object that holds other View
(and ViewGroup) objects in order to define the
layout of the user interface.
Layout Types
Linear Layout
LinearLayout is a view group that aligns all children in
a single direction, vertically or horizontally.
Relative Layout
• HTML
• HTML + Basic
<Style>
• HTML +
<Style> + CSS
• HTML + CSS3
• HTML + CSS3 +
Ajax + Anim
Progressive Enhancement
Our unstyled experience or markup viewed in its
rendered form is at the center. We can assume that all
devices can show at least this level of presentation.
Next, we add basic styling techniques for our lowest
common denominator devices that support both our
markup plus very basic styling techniques.
We continue to add layers until we reach the best
possible experience on the outside.
Progressive Enhancement
It should be noted that you can add a desktop
layer to your site using progressive
enhancement.
There is absolutely nothing wrong with this
Fragments
Mini-activities, each with its own set of views
One or more fragments can be embedded in an Activity
You can do this dynamically as a function of the device type (tablet or not)
or orientation
You might
decide to run
a tablet in
portrait mode
with the handset
model of only
one fragment
in an Activity
Activity=
Fragment 2 Fragments
TextView Fragment 1
FragementTransaction: replace
Fragment 1 with Fragment 2
Activity
TextView Fragment 2
Fragment Lifecycle
Fragment in an Activity---Activity
Lifecyle influences
Activity paused all its fragments paused
Activity destroyed all its fragments are destroyed
Activity running manipulate each fragment
independently.
Fragment transaction add, remove,
etc.
adds it to a back stack that's managed by the activity—each
back stack entry in the activity is a record of the fragment
transaction that occurred.
The back stack allows the user to reverse a fragment
transaction (navigate backwards), by pressing the Back
button.
Fragment methods (callback
functions)
onAttach(Activity) called once the fragment is associated with its
activity.
onCreate(Bundle) called to do initial creation of the fragment.
onCreateView(LayoutInflater, ViewGroup, Bundle) creates and
returns the view hierarchy associated with the fragment.
onActivityCreated(Bundle) tells the fragment that its activity has
completed its own Activity.onCreate.
onStart() makes the fragment visible to the user (based on its
containing activity being started).
onResume() makes the fragment interacting with the user (based
on its containing activity being resumed).
Fragment methods (callback
functions)
As a fragment is no longer being used, it goes through a reverse series
of callbacks:
onPause() fragment is no longer interacting with the user either