0% found this document useful (0 votes)
15 views7 pages

Components of Screen

The document discusses the components of a mobile application screen in Android, including the action bar, content area, and different types of views and view groups. It covers common layouts like linear, relative, and constraint layouts. It also describes attributes and measurement units used in layouts.

Uploaded by

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

Components of Screen

The document discusses the components of a mobile application screen in Android, including the action bar, content area, and different types of views and view groups. It covers common layouts like linear, relative, and constraint layouts. It also describes attributes and measurement units used in layouts.

Uploaded by

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

Mobile Application Development

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

 A View is defined as the user interface which is used to


create interactive UI components such
as TextView, ImageView, EditText, RadioButton, etc.,
and is responsible for event handling and drawing.
 They are Generally Called Widgets.

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

 There are many types of layout.


o Linear Layout
o Absolute Layout
o Table Layout
o Frame Layout
o Relative 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.

Different Attribute of the Layouts

XML attributes Description

Used to specify the id of


android:id
the view.

Used to declare the width


android:layout_width of View and ViewGroup
elements in the layout.

Used to declare the height


android:layout_height of View and ViewGroup
elements in the layout.

android:layout_marginLeft Used to declare the extra


XML attributes Description

space used on the left side


of View and ViewGroup
elements.

Used to declare the extra


space used on the right side
android:layout_marginRight
of View and ViewGroup
elements.

Used to declare the extra


space used in the top side
android:layout_marginTop
of View and ViewGroup
elements.

Used to declare the extra


space used in the bottom
android:layout_marginBottom
side of View and
ViewGroup elements.

Used to define how child


android:layout_gravity Views are positioned in the
layout.
Units of Measurement
Sr.N
Unit & description
o

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

1 Low density (ldpi)


120 dpi

2 Medium density (mdpi)


160 dpi

3 High density (hdpi)


240 dpi

4 Extra High density (xhdpi)


320 dpi

You might also like