0% found this document useful (0 votes)
45 views19 pages

UI Architecture

Uploaded by

Nourisher Mugero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views19 pages

UI Architecture

Uploaded by

Nourisher Mugero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

USER INTERFACE

ARCHITECTURE
APPLICATION CONTEXT
• Application Context is It is an instance which is the singleton and can
be accessed in an activity via getApplicationContext(). This context is
tied to the lifecycle of an application. The application context can be
used where you need a context whose lifecycle is separate from the
current context or when you are passing a context beyond the scope
of an activity.
Cont…
• Activity Context
This context is available in an activity. This context is tied to the
lifecycle of an activity. The activity context should be used when you
are passing the context in the scope of an activity or you need the
context whose lifecycle is attached to the current context.
• getContext() in ContentProvider
This context is the application context and can be used similar to the
application context. This can be accessed via getContext() method.
INTENTS
• Intent is a simple message object that is used to communicate
between android components such as activities,content providers,
broadcast receivers and services. Intents are also used to transfer
data between activities.
• The implicit intent is the intent where instead of defining the exact
components, you define the action that you want to perform for
different activities.An explicit intent is Intent where you explicitly
define the component that needs to be called by the Android System.
• An explicit intent is one that you can use to launch a specific app
component, such as a particular activity or service in your app
ACTIVITY LIFECYCLE
MULTIPLE SCREEN SIZES
• Android devices come in all shapes and sizes, so your app's layout
needs to be flexible. That is, instead of defining your layout with rigid
dimensions that assume a certain screen size and aspect ratio, your
layout should
gracefully respond to different screen sizes and orientations.
• The best way to create a responsive layout for different screen sizes is
to use Constraint Layout as the base layout in your UI. Constraint
Layout allows you to specify the position and size for each view
according to spatial relationships with other views in the layout. This
way, all the views can move and stretch together as the screen size
changes
Cont…
• The easiest way to build a layout with Constraint Layout is to use the
Layout Editor in Android Studio. It allows you to drag new views to
the layout, attach their constraints to the parent view and other
sibling views, and edit the view's properties, all without editing any
XML by hand.
USER INTERFACE DESIGN
FORM WIDGETS
• Widgets enable users to interact with an Android Studio application page.
There are various kinds of widgets, such as Buttons and TextViews.
• To see all the widgets at your disposal, create a new application project
called ―Widgets‖ and select "empty activity". Call your activity
―MainActivity‖.
• There are two components of each Android activity: the XML (Extensible
Markup Language) design (the beauty) and the Java text (the brains).
Cont…
• On the activity_main.xml page, you can see the full widgets palette
underneath the various layout options.
• As you can see, there are 20 widgets available for you to use. In this
guide, we’ll discuss TextViews and Buttons, which are probably the
most common widgets in Android development.
TEXT FIELDS
• A text field allows the user to type text into your app. It can be either
single line or multi-line. Touching a text field places the cursor and
automatically displays the keyboard. In addition to typing, text fields
allow for a variety of other activities, such as text selection (cut, copy,
paste) and data look-up via auto-completion.
• You can add a text field to your layout with the EditText object. You
should usually do so in your XML layout with a <EditText> element.
• Text fields can have different input types, such as number, date,
password, or email address.
LAYOUTS
• A layout defines the visual structure for a user interface, such as the
UI for an activity or app widget. Each layout has a set of attributes
which define the visual properties of that layout. There are few
common attributes among all the layouts and there are other
attributes which are specific to that layout. Following are common
attributes and will be applied to all the layouts.
BUTTON CONTROL
• Button is a user interface control which is used to perform an action
whenever the user click or tap on it.Buttons in android will contains a
text or an icon or both and perform an action when user touches it.
• Different types of buttons available are ImageButton, ToggleButton,
RadioButton.
TOGGLE BUTTONS
• A toggle button allows the user to change a setting between two
states.
• You can add a basic toggle button to your layout with the
ToggleButton object. Android 4.0 (API level 14)introduces another
kind of toggle button called a switch that provides a slider control,
which you can add with a Switch object.SwitchCompat is a version of
the Switch widget which runs on devices back to API 7
SPINNERS / COMBO BOXES
• Spinners provide a quick way to select one value from a set. In the
default state, a spinner shows its currently selected value.
• Touching the spinner displays a dropdown menu with all other
available values, from which the user can select a new one.
IMAGES
public abstract class Image
extends Object implements AutoCloseable
java.lang.Object
android.media.image
• A single complete image buffer to use with a media source such as a
MediaCodec or a CameraDevice.
• This class allows for efficient direct application access to the pixel data of
the Image through one or more
ByteBuffers. Each buffer is encapsulated in a Plane that describes the
layout of the pixel data in that plane. Due
to this direct access, and unlike the Bitmap class, Images are not directly
usable as UI resources.
MENU
• android, Options Menu is a primary collection of menu items for an
activity and it is useful to implement actions that have a global impact
on the app, such as Settings, Search, etc.

• In case, if we define items for the options menu in both activity or


fragment, then those items will be combine
and display in UI.
DIALOG
• A dialog is a small window that prompts the user to make a decision
or enter additional information. A dialog does not fill the screen and
is normally used for modal events that require users to take an action
before they can proceed.
• The Dialog class is the base class for dialogs, but you should avoid
instantiating Dialog directly. Instead, use
one of the following subclasses:
Cont…
1. AlertDialog : A dialog that can show a title, up to three buttons, a
list of selectable items, or a custom layout.
2. DatePickerDialog or TimePickerDialog : A dialog with a pre-defined
UI that allows the user to select a
date or time.
THE END

You might also like