Components of Screen
Components of Screen
UNIT II
Components of Screen
A typical user interface of an android application consists
of action bar and the application content area.
Main Action Bar
View Control
Content Area
Split Action Bar
The basic unit of android application is the activity.
A UI is defined in an xml file.
During compilation, each element in the XML is
compiled into equivalent Android GUI class with
attributes represented by methods.
Every application is a combination of View and
ViewGroup.
an android application contains a large number of
activities
Can say each activity is one page of the application.
Each activity contains multiple user interface
components and those components are the instances of
the View and ViewGroup.
All the elements in a layout are built using a hierarchy
of View and ViewGroup objects.
View
ViewGroup
act as a base class for layouts and layouts parameters
that hold other Views or ViewGroups and to define the
layout properties.
They are Generally Called layouts.
Types of layout
Linear Layout
Linear layout is further divided into horizontal and
vertical layout.
It means it can arrange views in a single column or in a
single row.
Example
<?xml version=”1.0” encoding=”utf-8”?>
<LinearLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:orientation=”vertical” >
<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”@string/hello” />
</LinearLayout>
Android Relative Layout:
o RelativeLayout is a ViewGroup subclass, used to
specify the position of child View elements relative
to each other like (A to the right of B) or relative to
the parent (fix to the top of the parent).
Android Constraint Layout:
o ConstraintLayout is a ViewGroup subclass, used to
specify the position of layout constraints for every
child View relative to other views present.
o A ConstraintLayout is similar to a RelativeLayout,
but having more power.
Android Frame Layout:
o FrameLayout is a ViewGroup subclass, used to
specify the position of View elements it contains on
the top of each other to display only a single View
inside the FrameLayout.
Android Table Layout:
o TableLayout is a ViewGroup subclass, used to
display the child View elements in rows and
columns.
Android Web View:
o WebView is a browser that is used to display the
web pages in our activity layout.
Android ListView:
o ListView is a ViewGroup, used to display
scrollable lists of items in a single column.
Android Grid View:
o GridView is a ViewGroup that is used to display a
scrollable list of items in a grid view of rows and
columns.
dp
1 Density-independent pixel. 1 dp is equivalent to one pixel
on a 160 dpi screen.
sp
2 Scale-independent pixel. This is similar to dp and is
recommended for specifying font sizes
pt
3 Point. A point is defined to be 1/72 of an inch, based on
the physical screen size.
px
4 Pixel. Corresponds to actual pixels on the screen
Screen Densities
Sr.No Density & DPI