0% found this document useful (0 votes)
6 views

LECTURE 2

Uploaded by

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

LECTURE 2

Uploaded by

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

CP 313: MOBILE APPLICATIONS DEVELOPMENT

Android Project Structure

Android Studio is the official IDE (Integrated


Development Environment) developed by JetBrains
community which is freely provided by Google for
android app development.
After completing the setup of Android Architecture
we can create android application in the studio.
Android Project Structure(Manifests Folder)

Manifests folder contains AndroidManifest.xml for our


creating the android application.
 This file contains information about our application such as
android version, metadata, states package for Kotlin file and
other application components.
 It acts as an intermediator between android OS and our
application.
Android Project Structure (Manifest file)
Android Project Structure (Manifest file)

Among many other things, the manifest file is required to declare the following:
• The app's package name.
usually matches your code's namespace. The Android build tools use this to
determine the location of code entities when building your project. When
packaging the app, the build tools replace this value with the application ID
from the Gradle build files, which is used as the unique app identifier on the
system and on Google Play.
Android Project Structure (Manifest file)

An intent-filter
This is a tag used in the manifest file of your app, generally for two
basic reasons:-
To specify which activity of your app is going to be
the launcher activity(the home screen).
It is used to register broadcast receivers or services.
Android Project Structure (Manifest file)

App components
For each app component that you create in your app, you must declare a
corresponding XML element in the manifest file:
<activity> for each subclass of Activity.
<service> for each subclass of Service.
<receiver> for each subclass of BroadcastReceiver.
<provider> for each subclass of ContentProvider.
If you subclass any of these components without declaring it in the manifest
file, the system cannot start it.
Android Project Structure (Manifest file)

Icons and labels


A number of manifest elements have icon and label attributes for
displaying a small icon and a text label, respectively, to users for the
corresponding app component.
In every case, the icon and label that are set in a parent element become
the default icon and label value for all child elements. For example, the
icon and label that are set in the <application> element are the default icon
and label for each of the app's components (such as all activities).
Android Project Structure (Manifest file)

Permissions
Android apps must request permission to access sensitive user data (such as
contacts and SMS) or certain system features (such as the camera and internet
access).
Each permission is identified by a unique label.
For example, an app that needs to send SMS messages must have the following
line in the manifest:
<manifest ... >
<uses-permission android:name="android.permission.SEND_SMS"/>
...
</manifest>
Android Project Structure (Manifest file)

Device compatibility
The manifest file is also where you can declare what types of hardware or
software features your app requires, and thus, which types of devices your app is
compatible with.
Google Play Store does not allow your app to be installed on devices that don't
provide the features or system version that your app requires.
There are several manifest tags that define which devices your app is compatible
with.
The following are just a couple of the most common tags.
Android Project Structure (Manifest file)

<uses-feature>
The <uses-feature> element allows you to declare hardware and software features
your app needs. For example, if your app cannot achieve basic functionality on a
device without a compass sensor, you can declare the compass sensor as required
with the following manifest tag:

<manifest ... >


<uses-feature android:name="android.hardware.sensor.compass“
android:required="true" />
...
</manifest>
Android Project Structure (Manifest file)

<uses-sdk>
Each successive platform version often adds new APIs not available in the
previous version.
To indicate the minimum version with which your app is compatible, your
manifest must include the <uses-sdk> tag and its minSdkVersion attribute.
Android Project Structure (Java folder)

Java folder contains all the java and Kotlin source code (.java) files which we
create during the app development, including other Test files.
If we create any new project using java, by default the class file
MainActivity.java file will create automatically under the package name
“com.example.myapplication1” like as shown below.
Android Project Structure (Java folder)
Android Project Structure (Resource (res) folder)

Resource folder is the most important folder because it


contains all the non-code sources like images, XML layouts,
UI strings for our android application
Android Project Structure (Resource (res) folder)
Android Project Structure (Resource (res) folder)

res/drawable folder
It contains the different type of images used for the development of
the application.
We need to add all the images in drawable folder for the application
development.
Android Project Structure (Resource (res) folder)

res/layout folder
Layout folder contains all XML layout files which we used to define
the user Interface of our application.
It contains the activity_main.xml file.
Android Project Structure (Resource (res) folder)

res/mipmap folder
This folder contains launcher.xml files to define icons which are used
to show on the home screen.
It contains different density type of icons depends upon the size of the
device such as hdpi, mdpi, xhdpi.
Android Project Structure (Resource (res) folder)

res/values folder
Values folder contains a number of XML files like strings, dimens,
colors and styles definitions.
One of the most important file is strings.xml file which contains the
resources.
Android Project Structure (Resource (res) folder)

A menu
This resource defines an application menu (Options Menu, Context
Menu, or submenu) that can be inflated with MenuInflater.
Android Project Structure (Gradle Scripts folder)

Gradle means automated build system and it contains number of


files which are used to define a build configuration which can be
apply to all modules in our application.
 In build.gradle (Project) there are build scripts and in build.gradle
(Module) plugins and implementations are used to build
configurations that can be applied to all our application modules.
Layouts in android
Android Layout is used to define the user interface that holds the
UI controls or widgets that will appear on the screen of an android
application or activity screen.
Each activity contains multiple user interface components and those
components are the instances of the View and ViewGroup
Layouts in android
A layout defines the structure for a user interface in your app, such as
in an activity.
All elements in the layout are built using a hierarchy of View and
ViewGroup objects.
A View usually draws something the user can see and interact with.
ViewGroup is an invisible container that defines the layout structure
for View and other ViewGroup objects.
Layouts in android
Layouts in android
The View objects are usually called "widgets" and can be
one of many subclasses, such as Button or TextView.
The ViewGroup objects are usually called "layouts" can be
one of many types that provide a different layout structure,
such as LinearLayout or ConstraintLayout .
Layouts in android(LinearLayout)
LinearLayout is a view group that aligns all children in a single
direction, vertically or horizontally.
Layouts in android(common properties)
android:id
This is the ID which uniquely identifies the view.
android:layout_width
This is the width of the layout.
android:layout_height
This is the height of the layout

android:layout_marginTop
This is the extra space on the top
side of the layout.
Layouts in android(common properties)
android:layout_marginBottom
This is the extra space on the bottom side of the layout.
android:layout_marginLeft
This is the extra space on the left side of the layout.
android:layout_marginRight
This is the extra space on the right side of the layout.
android:layout_gravity
This specifies how child Views are positioned.
Layouts in android(common properties)
android:layout_weight
This specifies how much of the extra space in the layout
should be allocated to the View.
Layouts in android(Relative Layout)
RelativeLayout is a view group that displays child views in relative positions.
RelativeLayout enables you to specify how child views are positioned relative to
each other.
The position of each view
can be specified as relative to
sibling elements or relative to the parent.
Layouts in android(Table Layout)
TableLayout - displays elements in the form of a table, with rows and
columns.
Android UI Controls
There are number of UI controls provided by Android that
allow you to build the graphical user interface for your app.
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.
Android UI Controls(attributes of text view)
android:id
This is the ID which uniquely identifies the control.
android:capitalize
If set, specifies that this TextView has a textual input method and should automatically capitalize
what the user types.
android:hint
Hint text to display when the text is empty.
android:password
Whether the characters of the field are displayed as password dots instead of themselves. Possible
value either "true" or "false".
Android UI Controls(Edit Text)
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.
Android UI Controls(Button)
A Button is a Push-button which can be pressed, or clicked, by the
user to perform an action.
Android UI Controls(Check Box)
A CheckBox is an on/off switch that can be toggled by the
user.
You should use check-boxes when presenting users with a
group of selectable options that are not mutually exclusive.
Android UI Controls(Radio Button)
A RadioButton has two states: either checked or unchecked.
This allows the user to select one option from a set.
Android UI Controls(Spinner)
Spinner allows you to select an item from a drop down
menu
END

You might also like