Unit 03
Unit 03
AndroidManifest.xml:
• The manifest file is an important part of our app because it defines the structure and
metadata of our application, its components, and its requirements.
• This file includes nodes for each of the Activities, Services, Content Providers and
Broadcast Receiver that make the application and using Intent Filters and Permissions,
determines how they co-ordinate with each other and other applications.
• Java:
• The Java folder contains the Java source code files. These files are used as a controller
for controlled UI (Layout file). It gets the data from the Layout file and after processing
1
that data output will be shown in the UI layout. It works on the backend of an Android
application.
• drawable: A Drawable folder contains resource type file (something that can be
drawn). Drawables may take a variety of file like Bitmap (PNG, JPEG), Nine Patch, Vector
(XML), Shape, Layers, States, Levels, and Scale.
• layout: A layout defines the visual structure for a user interface, such as the UI for an
Android application. This folder stores Layout files that are written in XML language
• mipmap: Mipmap folder contains the Image Asset file that can be used in Android
Studio application. You can generate the icon types like Launcher icons, Action bar and
tab icons, and Notification icons.
• colors.xml: colors.xml file contains color resources of the Android application. Different
color values are identified by a unique name that can be used in the Android application
program.
• strings.xml: The strings.xml file contains string resources of the Android application.
The different string value is identified by a unique name that can be used in the Android
application program. This file also stores string array by using XML language.
• Below is a sample strings.xml file:
• <resources>
• <string name="app_name">MM Polytechnic</string>
• </resources>
• styles.xml: The styles.xml file contains resources of the theme style in the Android
application. This file is written in XML language
• build.gradle(Module: app): This defines the module-specific build configurations. Here
you can add dependencies what you need in your Android application.
1. Activity Lifecycle
The Activity class is the entry point for user interaction. Its lifecycle methods dictate
the control flow:
onCreate(): Called when the activity is created. Used for initialization (e.g.,
inflating layouts, initializing components).
onStart(): Called when the activity becomes visible to the user.
onResume(): Called when the activity starts interacting with the user.
onPause(): Called when the activity is partially obscured (e.g., another activity
comes into focus).
onStop(): Called when the activity is no longer visible.
onDestroy(): Called when the activity is destroyed.
onRestart(): Called when the activity restarts after being stopped.
2
2. Fragment Lifecycle
Fragments are reusable components within activities and have a similar lifecycle:
onAttach()
onCreate()
onCreateView()
onStart()
onResume()
onPause()
onStop()
onDestroyView()
onDestroy()
onDetach()
3. Service Lifecycle
onCreate()
onStartCommand(): Handles service requests.
onDestroy()
4. Broadcast Receivers
5. Intents
Android projects follow a standardized directory structure for organizing code and
resources:
1. app/
3
a. src/
main/
o java/: Contains Java/Kotlin source files.
o res/: Resource files.
layout/: XML layout files.
drawable/: Images and vector assets.
values/: XML files for colors, strings, styles, dimensions, etc.
menu/: Menu definitions.
o AndroidManifest.xml: Defines the app structure, components, and
permissions.
test/: Unit test cases.
androidTest/: Instrumentation tests.
b. build/
2. gradle/
3. .idea/
4. External Directories
Component of Layout :-
1. View Components
These are the building blocks of the UI, representing individual interactive or static
elements.
Types of Layouts
3. Specialized Components
RecyclerView: Displays large data sets in a list or grid, replacing the older
ListView.
ListView: Displays scrollable lists (deprecated for RecyclerView in modern apps).
GridView: Displays items in a grid format.
ScrollView: Enables vertical scrolling for a group of views.
ViewPager: Allows horizontal swiping between pages or fragments.
Navigation Components
5
4. Advanced Components
5. System UI Components
Fundamentals of UI Design :-
Material Design: Follow Google's Material Design principles for consistency, hierarchy,
motion, and responsiveness.
6
o Support multiple languages and regions.
10. Testing:
o Test UI on multiple screen sizes and devices.
o Use tools like Espresso and Layout Inspector for optimization.
1. Linear Layout
3. Frame Layout
Description: Stacks all child views on top of each other, with the most recent
child drawn last (on top).
Key Attributes:
o Typically used to display a single child or overlap multiple views.
Advantages:
o Simple for single-view or overlay use cases.
4. Table Layout
Description: Arranges child views into rows and columns like a table.
Key Attributes:
o TableRow: Defines a row within the table.
o All children inside a TableRow are arranged horizontally.
o
Advantages:
7
o Useful for structured layouts like forms.
Description: Positions child views relative to each other or the parent container.
Key Attributes:
o layout_alignParentTop, layout_alignParentStart: Positions a view relative to the
parent.
o layout_toRightOf, layout_below: Positions a view relative to another view.
Advantages:
o Flexible and suitable for complex designs.
Disadvantages:
o Harder to maintain for larger layouts.
For modern and complex designs, prefer ConstraintLayout for better performance
and flexibility.