Assignmen1
Assignmen1
Submitted By:
Eman Iftikhar
Submitted To:
Sir Aoun
Department:
BS Computer Science (6th)
Topic:
User Interface Elements introduction (layouts &
Widgets)
Subject:
Mobile Application Development
Roll No:
01
User interface (UI) elements are the parts we use to build apps or
websites. They add interactivity to a user interface, providing touchpoints for
the user as they navigate their way around; think buttons, scrollbars, menu
items, and checkboxes.
User interface (UI) design involves structuring the visual elements of an app or website using
layouts and widgets. Layouts determine the overall structure and arrangement of elements on
the screen, while widgets are individual UI components like buttons, text fields, or images
that users interact with.
Layouts:
Definition:
Layouts are the foundational structures that organize UI elements on a screen, determining
their positioning, size, and arrangement.
Layout Types
There are number of Layouts provided by Android which you will use in almost all the
Android applications to provide different view, look and feel.
1.Linear Layout
Linear Layout is a view group that aligns all children in a single direction, vertically or
horizontally.
2. Relative Layout
Relative Layout is a view group that displays child views in relative positions.
3. Table Layout
Table Layout is a view that groups views into rows and columns.
4. Absolute Layout
Absolute Layout enables you to specify the exact location of its children.
5.Frame Layout
The Frame Layout is a placeholder on screen that you can use to display a single view.
6.List View
List View is a view group that displays a list of scrollable items.
7.Grid View
Grid View is a View Group that displays items in a two-dimensional, scrollable grid.
Layout Attributes
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:
1.android:id
This is the ID which uniquely identifies the view.
2.android: layout width
This is the width of the layout.
3.android: layout height
This is the height of the layout
4.android: layout_marginTop
This is the extra space on the top side of the layout.
5.android: layout_marginBottom
This is the extra space on the bottom side of the layout.
6.android: layout_marginLeft
This is the extra space on the left side of the layout.
7.android: layout_marginRight
This is the extra space on the right side of the layout.
8.android: layout_gravity
This specifies how child Views are positioned.
9.android: layout_weight
This specifies how much of the extra space in the layout should be allocated to the View.
Here width and height are the dimension of the layout/view which can be specified in terms
of dp (Density-independent Pixels), sp (Scale-independent Pixels), pt (Points which is 1/72 of
an inch), px(Pixels), mm (Millimeters) and finally in (inches).
You can specify width and height with exact measurements but more often, you will use one
of these constants to set the width or height −
android: layout width=wrap content tells your view to size itself to the dimensions
required by its content.
android: layout_width=fill_parent tells your view to become as big as its parent
view.
Widgets:
Definition:
Widgets are the individual UI components that users interact with, such as buttons, text
fields, images, and more.
Common Types of Widgets:
1. Text and Labels
o Display static text.
2. Input Fields
o Allow users to enter data.
3. Buttons
o Trigger actions.
7. Navigation Widgets
o Menus, tabs, drawers for navigating between screens.