Notes 3
Notes 3
Notes 3
In an Android application, the user interface is built using View and ViewGroup objects. There are many types of
views and view groups, each of which is a descendant of the View class.
View objects are the basic units of user interface expression on the Android platform. The View class serves as the
base for subclasses called "widgets," which offer fully implemented UI objects, like text fields and buttons. The
ViewGroup class serves as the base for subclasses called "layouts," which offer different kinds of layout
architecture, like linear, tabular and relative.
A View object is a data structure whose properties store the layout parameters and content for a specific
rectangular area of the screen. A View object handles its own measurement, layout, drawing, focus change,
scrolling, and key/gesture interactions for the rectangular area of the screen in which it resides. As an object in the
user interface, a View is also a point of interaction for the user and the receiver of the interaction events.
View Hierarchy
On the Android platform, you define an Activity's UI using a hierarchy of View
and ViewGroup nodes, as shown in the diagram below. This
hierarchy tree can be as simple or complex as you need it to be,
and you can build it up using Android's set of predefined widgets
and layouts, or with custom Views that you create yourself.
Application Context
Widgets
A widget is a View object that serves as an interface for interaction with the user. Android provides a set of fully
implemented widgets, like buttons, checkboxes, and text-entry fields, so you can quickly build your UI. Some
widgets provided by Android are more complex, like a date picker, a clock, and zoom controls. But you're not
limited to the kinds of widgets provided by the Android platform. If you'd like to do something more customized and
create your own actionable elements, you can, by defining your own View object or by extending and combining
existing widgets.
Layout
The most common way to define your layout and express the view hierarchy is with an XML layout file. XML offers
a human-readable structure for the layout, much like HTML. Each element in XML is either a View or ViewGroup
object (or descendant thereof). View objects are leaves in the tree, ViewGroup objects are branches in the tree.
Intents in Android
In Android, it is quite usual for users to witness a jump from one application to
another as a part of the whole process, for example, searching for a location on the
browser and witnessing a direct jump into Google Maps or receiving payment links
in Messages Application (SMS) and on clicking jumping to PayPal or GPay (Google
Pay). This process of taking users from one application to another is achieved by
passing the Intent to the system. Intents, in general, are used for navigating
among various activities within the same application, but note, is not limited to one
single application, i.e., they can be utilized from moving from one application to
another as well.
Intents could be Implicit, for instance, calling intended actions, and explicit as well,
such as opening another activity after some operations like onClick or anything
else. Below are some applications of Intents:
1. Sending the User to Another App
2. Getting a Result from an Activity
3. Allowing Other Apps to Start Your Activity
Important Method of Intent and their Description
Methods Description