You are on page 1of 53

An Industrial Training Report

on

Android Application Development


Submitted in partial fulfillment of the requirements
for the degree of

Bachelor of Technology
by
Sapna Jayram Shelar
PRN no: 2030331246012
under the guidance of
Prof. Pranita Jadhav

Department of Information Technology


Dr. Babasaheb Ambedkar Technological University,
Lonere-402103, Dist. Raigad, (MS) INDIA.
December 21, 2022
Certificate

An Industrial training report, Android Application Development


submitted by Sapna Jayram Shelar (2030331246012), is approved
for the partial fulfillment of the requirements for the degree of Bachelor
of Technology of Dr. Babasaheb Ambedkar Technological University,
Lonere - 402 103, Raigad (MS).

Guide Head of Department, IT


Prof. Pranita Jadhav Dr. Sanjay R. Sutar

Place: Dr. Babasaheb Ambedkar Technological University, Lonere


Date:December 21, 2022

1
2
Contents

1 Introduction 1
1.1 What is Android? . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Need of Android? . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Features of Android . . . . . . . . . . . . . . . . . . . . . . 7

2 Steps Installation and Configure Android Studio 10


2.1 Installation Steps of JAVA JDK . . . . . . . . . . . . . . . 10
2.2 Installation Steps of Android Studio for Windows . . . . . 12
2.3 Installation Steps of Android Studio for Mac . . . . . . . . 16
2.4 Installation Steps of Android Studio for Linux . . . . . . . 16

3 Android Architecture 18

4 UI Components and Layouts 22

5 Designing User Interface With View 29

6 Conclusion 46

7 Reference 47

3
List of Figures

1.1 Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Characteristics of Android . . . . . . . . . . . . . . . . . . 6
1.3 Features of Android . . . . . . . . . . . . . . . . . . . . . . 9

2.1 Installation of JAVA JDK . . . . . . . . . . . . . . . . . . 11


2.2 Set the Android Studio and Android SDK installation lo-
cations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3 Create a New Shortcut for Android Studio . . . . . . . . . 14
2.4 Leave the Start Android Studio check box checked to run
this software . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3.1 Android Architecture . . . . . . . . . . . . . . . . . . . . . 19

4.1 View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2 View Group . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.3 Frame Layout . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.4 Linear Layout . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.5 Relative Layout . . . . . . . . . . . . . . . . . . . . . . . . 28

5.1 inheritance hierarchy of Designing user interface with view 30

4
5.2 TextView . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.3 EditText . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5.4 Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.5 ImageButton . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.6 ToggleButton . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.7 RadioButton . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.8 CheckBox . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

5
Chapter 1

Introduction

Android is a mobile operating system based on a modified version of the


Linux kernel and other open-source software, designed primarily for touch-
screen mobile devices such as smartphones and tablets. Android is devel-
oped by a consortium of developers known as the Open Handset Alliance
and commercially sponsored by Google. It was unveiled in November 2007,
with the first commercial Android device, the HTC Dream, being launched
in September 2008.
Most versions of Android are proprietary. The core components are
taken from the Android Open Source Project (AOSP), which is free and
open-source software (FOSS) primarily licensed under the Apache License.
When Android is installed on devices, the ability to modify the otherwise
free and open-source software is usually restricted, either by not provid-
ing the corresponding source code or by preventing reinstallation through
technical measures, thus rendering the installed version proprietary. Most
Android devices ship with additional proprietary software pre-installed,
most notably Google Mobile Services (GMS) which includes core apps

1
such as Google Chrome, the digital distribution platform Google Play,
and the associated Google Play Services development platform. As the
world’s most popular mobile platform, Android powers hundreds of mil-
lions of mobile devices in more than 190 countries around the world. It
has the largest installed base of any mobile platform and is still growing
fast. Every day another million users power up their Android-powered de-
vices for the first time and start looking for apps, games, and other digital
content.

1.1 What is Android?

Android is an open source and Linux-based Operating System for mobile


devices such as smartphones and tablet computers. Android was developed
by the Open Handset Alliance, led by Google, and other companies.
Android offers a unified approach to application development for mobile
devices which means developers need only develop for Android, and their
applications should be able to run on different devices powered by Android.
The first beta version of the Android Software Development Kit (SDK)
was released by Google in 2007 where as the first commercial version,
Android 1.0, was released in September 2008.
On June 27, 2012, at the Google I/O conference, Google announced
the next Android version, 4.1 Jelly Bean. Jelly Bean is an incremental
update, with the primary aim of improving the user interface, both in
terms of functionality and performance.
The source code for Android is available under free and open source

2
Figure 1.1: Android

3
software licenses. Google publishes most of the code under the Apache
License version 2.0 and the rest, Linux kernel changes, under the GNU
General Public License version 2. Android is an operating system and
programming platform developed by Google for mobile phones and other
mobile devices, such as tablets. It can run on many different devices from
many different manufacturers. Android includes a software development
kit (SDK) that helps you write original code and assemble software mod-
ules to create apps for Android users. Android also provides a marketplace
to distribute apps. All together, Android represents an ecosystem for mo-
bile apps.

1.2 Need of Android?

Android is a new generation mobile OS which runs on Linux Kernel there


are some following points which describes why we use Android OS:

1. Desktop: The Android phone adds widgets to the desktop the pur-
pose of for the Widget for example the Facebook allow us to update
our Facebook desktop the people with gets allow us to make possi-
ble different actions for a different contacts right from our desktop
the message will get allow us to immediately see our email from the
desktop.

2. Connectivity: On one page or desktop we could be able to have for


connecting device tool button like TURN ON Bluetooth,TURN ON
OFF WiFi,TURN ON OFF Mobile Network, TURN ON OFF GPS

4
and so on.These button let us a switch on off instantly which will
help us to conserve battery life.

3. Browser: The Android OS browser is one of the best browser on


the mobile market. It generally loads pages faster than Safari or any
other browser has flash support and simply does everything a browser
should do. for Example iphone has a safari browser.It is stable has no
flash support so we cannot watched YouTube videos or any related
wanted it is not flexible but monopolistic.

4. Open to Carrier: If we know the programming language then we are


open to Android world.

5. Market: Android OS has an Android market the Android apps are


free and work as well.

6. future: Future mobile phones are basically going to be smart phones.

7. Muti-Notification: Android phones have a multi notification system


with Android app have access to the notification system and call all
report.

8. Google Integration: Android has inbuilt Google support. For example


Google Map, gmail, etc.

9. Open Source: The code of android os as well as the app is available.

10. Endless Personalization: The Android cell phone allows to configura-


tion mobile to look and behave exactly like they want.

5
Figure 1.2: Characteristics of Android

6
1.3 Features of Android

There are numerous features of android. Some of them are listed below:

1. Connectivity: Android supports multiple connectivity technologies


including GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth,
Wi-Fi, LTE, NFC, and WiMAX.

2. Storage: SQLite, a lightweight relational database, is used for data


storage purposes.

3. Media support: Android supports various types of audio/video/still


media formats like H.263, H.264, MPEG-4 SP, AMR, AMR-WB,
AAC, HE-AAC, AAC 5.1, MP3, MIDI, Ogg Vorbis, WAV, JPEG,
PNG, GIF, BMP and WebP.

4. Web browser: The web browser available in Android is based on the


open-source Blink (previously WebKit) layout engine, coupled with
Chrome’s V8 JavaScript engine : Widgets are resizable, so users can
expand them to show more content or shrink them to save space
supporting HTML5 and CSS3.

5. Messaging: SMS and MMS are available forms of messaging, it also


includes threaded text messaging and Android Cloud To Device Mes-
saging (C2DM) and now supports the enhanced version of C2DM,
Android Google Cloud Messaging (GCM) is also a part of Android
Push Messaging services.

7
6. Multi-tasking: Multitasking of applications, with unique handling of
memory allocation, is available, using this users can jump from one
task to another and at the same time various applications can run
simultaneously.

7. Resizable widgets: Widgets are resizable, so users can expand them


to show more content or shrink them to save space.

8. Multi-touch: Android has native support for multi-touch which was


initially made available in handsets such as the HTC Hero.

9. Wi-Fi: A technology that lets apps discover and pair directly, over a
high-bandwidth peer-to-peer connection.

10. Screen capture: Android supports capturing a screenshot by pressing


the power and home-screen buttons at the same time. This feature
supports after Android 4.0.

11. Multi-Language: Android supports multiple languages, also supports


the single direction and bi-directional text.

8
Figure 1.3: Features of Android

9
Chapter 2

Steps Installation and Configure


Android Studio

2.1 Installation Steps of JAVA JDK

It is mandatory to download the Java JDK. There are only seven steps for
the installation process of Java JDK which are as follows:

1. Firstly, click on the following link to download JDK.


https://www.oracle.com/technetwork/java/javase/downloads/index.html

2. By clicking on the link given above you will be directed to the ORA-
CLE page, there will be some links as depicted in the above picture.

3. After that, click on Accept Agreement License.

4. Then, download the link as per your operating system that is Win-
dows, Mac, Linux.

10
Figure 2.1: Installation of JAVA JDK

5. After downloading the file, click on the downloaded file and install
JDK.

6. Now, after installation, we need to set the environment variable.

7. Lastly, to set environment variable, follow this, Control Panel-¿System


and Security-¿ System-¿ Advanced setting-¿Environment variable -¿
Add new path.
By following these steps you will successfully add the environment
variable. Now, we will see the installation process of Android studio
for Windows, Mac and Linux.

11
2.2 Installation Steps of Android Studio for Win-
dows

There are just three steps for installing Android studio for windows which
are as follows:

1. Firstly, to download Android Studio This will direct you to the official
website of Android Studio.

2. Then, click on download Android Studio as shown.

3. Lastly, click on the downloaded file and packages will install, auto-
matically. We are done with installation for windows and now you
can start making your application using Android Studio.
OR
Clicking Next took me to the following dialog box, which gives you
the option to decline installing the Android SDK (included with the
installer) and an Android Virtual Device (AVD).
I chose to keep the default settings. After clicking Next, you’ll be
taken to the license agreement dialog box. Accept the license to
continue the installation.
The next dialog box invites you to change the installation locations
for Android Studio and the Android SDK.
Change the location or accept the default locations and click Next.
The installer defaults to creating a shortcut for launching this pro-
gram, or you can choose to decline. I recommend that you create the

12
Figure 2.2: Set the Android Studio and Android SDK installation locations

13
Figure 2.3: Create a New Shortcut for Android Studio

14
Figure 2.4: Leave the Start Android Studio check box checked to run this software

15
shortcut, then click the Install button to begin installation.
The resulting dialog box shows the progress of installing Android
Studio and the Android SDK. Clicking the Show Details button will
let you view detailed information about the installation progress.
The dialog box will inform you when installation has finished.
To complete your installation, leave the Start Android Studio box
checked and click Finish.

2.3 Installation Steps of Android Studio for Mac

Following are the steps for installing Android studio for Mac:

1. Go on official page of Android Studio where you will get an option to


download Android Studio.

2. After that, click on the button and dmg file will download.

3. Open the dmg file by double-clicking on it.

4. Then, drag and drop the Android Studio icon in the application
folder. This will copy all the files of Android Studio in the appli-
cations folder and you will be able to see the Android Studio icon in
the application.

2.4 Installation Steps of Android Studio for Linux

Just follow these three steps to download Android Studio for Linux:

16
1. Download Android Studio file.

2. Now,unzip and extract the downloaded file.

3. Now to run Android Studio, open terminal and then open bin direc-
tory and execute the studio.sh command on the terminal.

4. And then you can build your Android applications on your Linux
system as well.

17
Chapter 3

Android Architecture

Android operating system is a stack of software components which is


roughly divided into five sections and four main layers as shown below
in the architecture diagram. Linux kernel:- At the bottom of the layers is
Linux - Linux 3.6 with approximately 115 patches. This provides a level
of abstraction between the device hardware and it contains all the essen-
tial hardware drivers like camera, keypad, display etc. Also, the kernel
handles all the things that Linux is really good at such as networking and
a vast array of device drivers, which take the pain out of interfacing to
peripheral hardware.
Libraries:- On top of Linux kernel there is a set of libraries including
open-source Web browser engine WebKit, well known library libc, SQLite
database which is a useful repository for storage and sharing of application
data, libraries to play and record audio and video, SSL libraries responsible
for Internet security etc.
Android Libraries:- This category encompasses those Java-based li-
braries that are specific to Android development. Examples of libraries

18
Figure 3.1: Android Architecture

in this category include the application framework libraries in addition to


those that facilitate user interface building, graphics drawing and database
access. A summary of some key core Android libraries available to the An-
droid developer is as follows
android.app Provides access to the application model and is the cor-
nerstone of all Android applications.

1. android.content Facilitates content access, publishing and messaging


between applications and application components.

2. android.database Used to access data published by content providers


and includes SQLite database management classes.

3. android.opengl A Java interface to the OpenGL ES 3D graphics

19
rendering API.

4. android.os Provides applications with access to standard operating


system services including messages, system services and inter-process
communication.

5. android.text Used to render and manipulate text on a device display.

6. android.view The fundamental building blocks of application user


interfaces.

7. android.widget A rich collection of pre-built user interface compo-


nents such as buttons, labels, list views, layout managers, radio but-
tons etc.

8. android.webkit A set of classes intended to allow web-browsing ca-


pabilities to be built into applications.
Having covered the Java-based core libraries in the Android runtime,
it is now time to turn our attention to the C/C++ based libraries
contained in this layer of the Android software stack.

Android Runtime:- This is the third section of the architecture and


available on the second layer from the bottom. This section provides a
key component called Dalvik Virtual Machine which is a kind of Java Vir-
tual Machine specially designed and optimized for Android. The Dalvik
VM makes use of Linux core features like memory management and multi-
threading, which is intrinsic in the Java language. The Dalvik VM enables
every Android application to run in its own process, with its own instance

20
of the Dalvik virtual machine. The Android runtime also provides a set
of core libraries which enable Android application developers to write An-
droid applications using standard Java programming language.
Application Framework:- The Application Framework layer provides
many higher-level services to applications in the form of Java classes. Ap-
plication developers are allowed to make use of these services in their
applications.
The Android framework includes the following key services

1. Activity Manager Controls all aspects of the application lifecycle and


activity stack.

2. Content Providers Allows applications to publish and share data


with other applications.

3. Resource Manager Provides access to non-code embedded resources


such as strings, color settings and user interface layouts.

4. Notifications Manager Allows applications to display alerts and no-


tifications to the user.

5. View System An extensible set of views used to create application


user interfaces.

Applications:- You will find all the Android application at the top layer.
You will write your application to be installed on this layer only. Examples
of such applications are Contacts Books, Browser, Games etc.

21
Chapter 4

UI Components and Layouts

Android Layout is used to define the user interface that holds the UI con-
trols or widgets that will appear on the screen of an android application
or activity screen. Generally, every application is a combination of View
and ViewGroup. As we know, an android application contains a large
number of activities and we can say each activity is one page of the ap-
plication. So, 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 View-
Group 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.
A 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.
The Android framework will allow us to use UI elements or widgets in

22
Figure 4.1: View

23
Figure 4.2: View Group

two ways:
1. Use UI elements in the XML file

2. Create elements in the Kotlin file dynamically


Types of Android Layout:-
1. Android Linear Layout: LinearLayout is a ViewGroup subclass, used
to provide child View elements one by one either in a particular direc-
tion either horizontally or vertically based on the orientation property.

2. Android Relative Layout: 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).

24
3. Android Constraint Layout: ConstraintLayout is a ViewGroup sub-
class, used to specify the position of layout constraints for every child
View relative to other views present. A ConstraintLayout is similar
to a RelativeLayout, but having more power.

4. Android Frame Layout: 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.

5. Android Table Layout: TableLayout is a ViewGroup subclass, used


to display the child View elements in rows and columns.

6. Android Web View: WebView is a browser that is used to display the


web pages in our activity layout.

7. Android ListView: ListView is a ViewGroup, used to display scrol-


lable lists of items in a single column.

8. Android Grid View: GridView is a ViewGroup that is used to display


a scrollable list of items in a grid view of rows and columns.

Layout Managers (or simply layouts) are said to be extensions of the View-
Group class. They are used to set the position of child Views within the UI
we are building. We can nest the layouts, and therefore we can create ar-
bitrarily complex UIs using a c GridLayout- It was introduced in Android
4.0 (API level 14), the Grid Layout used a rectangular grid of infinitely
thin lines to lay out Views in a series of rows and columns. The Grid
Layout is incredibly flexible and can be used to greatly simplify layouts

25
and reduce or eliminate the complex nesting often required to construct
UIs using the layouts described before.ombination of layouts.
There is a number of layout classes in the Android SDK. They can be
used, modified or can create your own to make the UI for your Views,
Fragments and Activities. You can display your contents effectively by
using the right combination of layouts.
The most commonly used layout classes that are found in Android SDK
are:

1. FrameLayout- It is the simplest of the Layout Managers that pins


each child view within its frame. By default the position is the top-left
corner, though the gravity attribute can be used to alter its locations.
You can add multiple children stacks each new child on top of the one
before, with each new View potentially obscuring the previous ones.

2. LinearLayout- A LinearLayout aligns each of the child View in either


a vertical or a horizontal line. A vertical layout has a column of
Views, whereas in a horizontal layout there is a row of Views. It
supports a weight attribute for each child View that can control the
relative size of each child View within the available space.

3. RelativeLayout- It is flexible than other native layouts as it lets us to


define the position of each child View relative to the other views and
the dimensions of the screen.

26
Figure 4.3: Frame Layout

27
Figure 4.4: Linear Layout

Figure 4.5: Relative Layout

28
Chapter 5

Designing User Interface With View

view class represent the basic building block for user interface components.
A view 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.
A veiw group is a special view that can contain other views. The view
group is the best class for layouts and view containers. The view is the
component with Android providers to design the layouts of the app. A
view is a superclass for all the UI components. 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

29
Figure 5.1: inheritance hierarchy of Designing user interface with view

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. In this chapter deals
with how to design a page by using graphical user interface(GUI), as it
is very important to design a good looking page for apps in Android here
we will discuss GUI like TextView(Lable),Button, EditText(TextField),
CheckBox,etc.

• TextView: A TextView displays text to the user and optionally allows


them to edit it. A TextView is a complete text editor, however the
basic class is configured to not allow editing. In android, TextView
is a user interface control that is used to set and display the text to
the user based on our requirements. The TextView control will act
as like label control and it won’t allow users to edit the text.

30
Attributes/Properties of TextView:

• id: Id is an attribute used to uniquely identify a text view. Below is


the example code in which we set the id of a text view.

• gravity: The gravity attribute is an optional attribute which is used to


control the alignment of the text like left, right, center, top, bottom,
centervertical, centerhorizontal etc.

• text: text attribute is used to set the text in a text view. We can set
the text in xml as well as in the java class. Below is the example code
with explanation included in which we set the text AbhiAndroid in a
text view.

• textColor: textColor attribute is used to set the text color of a text


view. Color value is in the form of “argb”, “rgb”, “rrggbb”, or “aar-
rggbb”.

• textSize: textSize attribute is used to set the size of text of a text view.
We can set the text size in sp(scale independent pixel) or dp(density
pixel).

• background: background attribute is used to set the background of a


text view. We can set a color or a drawable in the background of a
text view.

• padding: padding attribute is used to set the padding from left, right,
top or bottom. In above example code of background we also set the
10dp padding from all the side’s of text view.

31
Figure 5.2: TextView

32
• EditText: A EditText is an overlay over TextView that configures
itself to be editable. It is the predefined subclass of TextView that
includes rich editing capabilities. Edittext refers to the widget that
displays an empty textfield in which a user can enter the required
text and this text is further used inside our application.

Attributes/Properties of EditText:

• id: Used to uniquely identify the control

• gravity: Used to specify how to align the text like left, right, center,
top, etc.

• hint: Used to display the hint text when text is empty.

• text: Used to set the text of the EditText.

• textSize: Used to set size of the text.

• textColor: Used to set color of the text. TextColor attribute of


TextView widget lets you set a color of your choice. You can pro-
vide the color as hex value in one of the four formats: rgb, argb,
rrggbb, or aarrggbb.

• textStyle: Used to set style of the text. For example, bold, italic,
bolditalic, etc. Text styles define three sizes for the formatted text -
’full’, ’short’ and ’narrow’

• textAllCaps:Used this attribute to show the text in capital letters.

• width: It makes the TextView be exactly this many pixels wide.

33
• height: It makes the TextView be exactly this many pixels tall.

• maxWidth: Used to make the TextView be at most this many pixels


wide.

• minWidth: Used to make the TextView be at least this many pixels


wide.

• background: Used to set background to this View.

• clickable: Used to set true when you want to make this View clickable.
Otherwise, set false.

• drawableBottom: Used to set drawable to bottom of the text in this


view.

• drawableEnd: Used to set drawable to end of the text in this view.

• drawableLeft: Used to set drawable to left of the text in this view.

• drawablePadding: Used to set drawable to right of the text in this


view.

• drawableStart: Used to set drawable to start of the text in this view.

• drawableTop: Used to set drawable to top of the text in this view.

• elevation: Used to set elevation to this view.

• padding: The padding attribute is used to set the padding from left,
right,top or bottom. In above example code of background we also
set the 10dp padding from all the slides of bottom.

34
Figure 5.3: EditText

35
• Button: A button consists of text or an icon (or both text and an icon)
that communicates what action occurs when the user touches it. An-
droid Button represents a push-button. The android.widget.Button
is subclass of TextView class and CompoundButton is the subclass
of Button class. There are different types of buttons in android such
as RadioButton, ToggleButton, CompoundButton etc.

Attributes/Properties of Button:

• id: Used to specify the id of the view.

• textColor: Used to the display color of the text.

• textSize: Used to the display size of the text.

• textStyle: Used to the display style of the text like Bold, Italic, etc.

• textAllCaps: Used to display text in Capital letters.

• background: Used to set the background of the view.

• padding: Used to set the padding of the view. the padding attribute
is used to set the padding from left, right, top or bottom. In above
example code of background we also set the 10dp padding from all
the slides of bottom.

• visibility: Used to set the visibility of the view.

• gravity: Used to specify the gravity of the view like center, top, bot-
tom, etc

36
Figure 5.4: Button

• ImageButton: In Android, ImageButton is used to display a normal


button with a custom image in a button. In simple words we can
say, ImageButton is a button with an image that can be pressed or
clicked by the users. By default it looks like a normal button with the
standard button background that changes the color during different
button states. An image on the surface of a button is defined within a
xml (i.e. layout ) by using src attribute or within java class by using
setImageResource() method. We can also set an image or custom
drawable in the background of the image button.

Attributes/Properties of ImageButton:

• id: Id is an attribute used to uniquely identify a image button.

• src: src is an attribute used to set a source file of image or you can

37
say image in your image button to make your layout look attractive.

• background: background attribute is used to set the background of


an image button. We can set a color or a drawable in the background
of a Button.

• padding: padding attribute is used to set the padding from left, right,
top or bottom of the ImageButton.

– paddingRight : set the padding from the right side of the image
button.
– paddingLeft : set the padding from the left side of the image
button.
– paddingTop : set the padding from the top side of the image
button.
– paddingBottom : set the padding from the bottom side of the
image button.
– padding : set the padding from the all side’s of the image button.

• Step 1: Create a new project and name it ImageButtonExample.

• Step 2: Right click on drawable- New- Drawable resource file and


create new xml file name customimage-buttton.xml.

• Step 3: Open app-layout- activity main.xml (or) main.xml.

• Step 4: Open app-package- MainActivity.java.

38
Figure 5.5: ImageButton

39
• ToggleButton: A toggle button allows the user to change a setting
between two states. You can add a basic toggle button to your layout
with the ToggleButton object. Android 4.0 (API level 14) introduces
another kind of toggle button called a switch that provides a slider
control, which you can add with a Switch object.

Attributes/Properties of ToggleButton:

• id: This supplies an identifier name for this view.

• disabledAlpha: This is the alpha to apply to the indicator when dis-


abled.

• textOff: This is the text for the button when it is not checked.

• textOn: This is the text for the button when it is checked.

• autoText: If set, specifies that this TextView has a textual input


method and automatically corrects some common spelling errors.

• drawableBottom: This is the drawable to be drawn below the text.

• drawableRight: This is the drawable to be drawn to the right of the


text.

• editable: If set, specifies that this TextView has an input method.

• text: This is the Text to display.

• background: This is a drawable to use as the background.

40
Figure 5.6: ToggleButton

• RadioButton: Radio buttons allow the user to select one option from
a set. You should use radio buttons for optional sets that are mu-
tually exclusive if you think that the user needs to see all available
options side-by-side. If it’s not necessary to show all options side-by-
side, use a spinner instead.To create each radio button option, create
a RadioButton in your layout. However, because radio buttons are
mutually exclusive, you must group them together inside a Radio-
Group. By grouping them together, the system ensures that only one
radio button can be selected at a time.
Beginning with Android RadioButton, A RadioButton is a button
that has two states, that are either check or uncheck. This means if
we click on a RadioButton it gets into Checked state and by default,
it comes in Unchecked State.

41
In the Android Radio button, one thing to be noted is, once it gets
into the checked state we cannot undo it. Generally, we use them
in our application to let the users select one option from a set of
options. Radio Button is one of the important Android UI controls,
as it provides an interactive User Interface for the users.

Attributes/Properties of RadioButton:

• id: It set a unique identity.

• checked: It specifies the current state of the button.

• gravity: It sets the alignment of the text.

• text: It sets the text for the Radio Button.

• textColor: It sets the color of the text.

• textSize: It sets the size of the text.

• textStyle: It sets the style of the text, like – bold, italics. Text styles
define three sizes for the formatted text - ’full’, ’short’ and ’narrow’

• background: It sets the color for the background of the button.

• padding: It sets the padding from left, right bottom or the top. In
above example code of background we also set the 10dp padding from
all the slides of bottom.

• onClick: It invokes the method onClick() when the button is clicked.

• visibility: It controls the visibility of the Radio Button.

42
Figure 5.7: RadioButton

43
• CheckBox: CheckBox is also a two-state button, it can have either
checked state or unchecked state. The major difference between An-
droid CheckBox and Android RadioButton is that checkboxes can be
unchecked manually. Android CheckBox is mostly useful when there
are multiple options the users are allowed to choose all the options
that are applicable.

Attributes/Properties of RadioButton:

• id: It set a unique identity

• checked: It specifies the current state of the CheckBox.

• gravity: It sets the alignment of the CheckBox.

• text: It sets the text for the Radio CheckBox.

• textColor: It sets the color of the text in the CheckBox.

• textSize: It sets the size of the text in CheckBox.

• textStyle: It sets the style of the text, like – bold, italics.

• background: It sets the color for the background of the CheckBox.

• padding: It sets the padding from left, right bottom or the top.

• onClick: It invokes the method onClick() when the button is clicked.

• visibility: It controls the visibility of the CheckBox.

44
Figure 5.8: CheckBox

45
Chapter 6

Conclusion

I’ve learned through my research that Android is a much more diverse


operating system than iOS and Windows Phone Mobile. Android has
grown rapidly over the past 4 years becoming the most used smartphone
operating system in the world. It’s because Android doesn’t release 1
phone from 1 company with 1 new OS every year, but countless phones
from numerous companies, adding their own twist, throughout the year,
developing gradually day-by-day. Android’s ability to customize is unpar-
alleled compared to Apple’s and Microsoft’s software allowing the user to
change and customize nearly every aspect of Android which most iPhone
and Windows 7 users wouldn’t dream possible. I am not one to say that
Android is better or worse than one OS, but is unique and incomparable
to other mobile operating systems.

46
Chapter 7

Reference

1. Thomas C. G. A. Jayanthila Devi


https://www.emerald.com/insight/content/doi/10.1108/AAOUJ-02-2018-
0013/full/html

2. Instituto Politecnico de Leiria, Leiria, Leiria, PT


https://ieeexplore.ieee.org/document/7975825/authorsauthors

3. Jones, M., Marsden, G., Ebooks Corporation. (2006).Mobile Inter-


action Design (1st ed.). John Wiley Sons, Ltd.
https://ebookcentral.proquest.com/lib/qut/detail.action?docID=255361

4. Neil, T., Ebooks Corporation. (2012). Mobile design pattern gallery:


UI patterns for mobile applications. O’Reilly Media.
https://ebookcentral.proquest.com/lib/qut/detail.action?docID=871556

47

You might also like