You are on page 1of 10

ANUBHA GAJARGAONKAR BE-A

118CP1334B ROLL NO-11

Experiment No 3

Aim: Develop an application that uses GUI components.

Theory:

The basic building block for user interface is a View object which is created from the View class
and occupies a rectangular area on the screen and is responsible for drawing and event handling.
View is the base class for widgets, which are used to create interactive UI components like
buttons, text fields, etc.
The ViewGroup is a subclass of View and provides invisible container that hold other Views or
other ViewGroups and define their layout properties.
At third level we have different layouts which are subclasses of ViewGroup class and a typical
layout defines the visual structure for an Android user interface and can be created either at run
time using View/ViewGroupobjects or you can declare your layout using simple XML file
main_layout.xml which is located in the res/layout folder of your project.
Android Layout Types
1 Linear Layout

LinearLayout is a view group that aligns all children in a single direction, vertically or
horizontally.

2 Relative Layout

RelativeLayout is a view group that displays child views in relative positions.

3 Table Layout

TableLayout is a view that groups views into rows and columns.


23 | P a g e
4 Absolute Layout

AbsoluteLayout enables you to specify the exact location of its children.

5 Frame Layout

The FrameLayout is a placeholder on screen that you can use to display a single view.

6 List View

ListView is a view group that displays a list of scrollable items.

7 Grid View

GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid.

Buttons

Depending on whether you want a button with text, an icon, or both, you can create the button
in your layout in three ways:
With text, using the Button class:

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_text"
... />
With an icon, using the ImageButton class:

<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/button_icon"
... />
With text and an icon, using the Button class with the android:drawableLeft attribute:

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_text"
24 | P a g e
android:drawableLeft="@drawable/button_icon"
... />

Creating a font family


A font family is a set of font files along with its style and weight details. In Android, you can
create a new font family as an XML resource and access it as a single unit, instead of referencing
each style and weight as separate resources. By doing this, the system can select the correct font
based on the text style you are trying to use.
To create a font family, perform the following steps in the Android Studio:

1.Right-click the font folder and go to New > Font resource file. The New Resource File window
appears.
2.Enter the file name, and then click OK. The new font resource XML opens in the editor.

3.Enclose each font file, style, and weight attribute in the <font> element. The following XML
illustrates adding font-related attributes in the font resource XML:
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="400"
android:font="@font/lobster_regular" />
<font
android:fontStyle="italic"
android:fontWeight="400"
android:font="@font/lobster_italic" />
</font-family>

AndroidUI Controls
There are number of UI controls provided by Android that allow you to build the graphical user
interface for your app.

Sr.No. UI Control & Description

1 TextView

This control is used to display text to the user.

25 | P a g e
2
EditText
26
EditText is a predefined subclass of TextView that includes rich editing |Page
capabilities.

3 AutoCompleteTextView

The AutoCompleteTextView is a view that is similar to EditText, except that it


shows a list of completion suggestions automatically while the user is typing.

4 Button

A push-button that can be pressed, or clicked, by the user to perform an action.

5 ImageButton

An ImageButton is an AbsoluteLayout which enables you to specify the exact


location of its children. This shows a button with an image (instead of text) that
can be pressed or clicked by the user.

6 CheckBox

An on/off switch that can be toggled by the user. You should use check box
when presenting users with a group of selectable options that are not mutually
exclusive.

7 ToggleButton

An on/off button with a light indicator.

8 RadioButton

The RadioButton has two states: either checked or unchecked.

9 RadioGroup

A RadioGroup is used to group together one or more RadioButtons.

10 ProgressBar

The ProgressBar view provides visual feedback about some ongoing tasks, such
as when you are performing a task in the background.
11 Spinner

A drop-down list that allows users to select one value from a set.

12 TimePicker

The TimePicker view enables users to select a time of the day, in either 24-hour
mode or AM/PM mode.

13 DatePicker

The DatePicker view enables users to select a date of the day.

Result:
Conclusion: In this experiment we learn Develop an application that uses GUI components

27 | P a g e
Questionnaire

1) What is view?
View is a basic building block of UI (User Interface) in android. A view is a small rectangular box that
responds to user inputs. Eg: EditText, Button, CheckBox, etc. ViewGroup is an invisible container of
other views (child views) and other ViewGroup.

2) What is ViewGroup?
ViewGroup. A ViewGroup is a special view that can contain other views. The ViewGroup is the base
class for Layouts in android, like LinearLayout , RelativeLayout , FrameLayout etc. In other words,
ViewGroup is generally used to define the layout in which views(widgets) will be set/arranged/listed on
the android screen.

3) Listout all android layout type?

 Linear Layout.
 Relative Layout.
 Constraint Layout.
 Table Layout.
 Frame Layout.
 List View.
 Grid View.
 Absolute Layout.

4) What is Linear Layout?

LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally.
You can specify the layout direction with the android:orientation attribute. ... A LinearLayout respects
margins between children and the gravity (right, center, or left alignment) of each child.

5) What is Grid View?

In android GridView is a view group that display items in two dimensional scrolling grid (rows and
columns), the grid items are not necessarily predetermined but they are automatically inserted to the
layout using a ListAdapter. Users can then select any grid item by clicking on it

6) Give fullform of XML?

XML stands for Extensible Markup Language. XML is a markup language much like HTML used to
describe data. XML tags are not predefined in XML.

28 | P a g e
7) List all Android UI Controls.
 Button. ...
 ImageButton.
 ToggleButton.
 RadioButton..
 RadioGroup. .
 CheckBox.

8) Write all checkbox attributes.


android:autoText
android:drawableBottom
android:drawableRight
android:text

9) What is the use of TimePicker?


Android Time Picker allows you to select the time of day in either 24 hour
or AM/PM mode. The time consists of hours, minutes and clock format.
Android provides this functionality through TimePicker class.

10)What is the function of RadioButton?

Android radio button is a widget which can have more than one option to
choose from. The user can choose only one option at a time. Each option
here refers to a radio button and all the options for the topic are together
referred to as Radio Group. Hence, Radio Buttons are used inside a
RadioGroup.

You might also like