Skip to content

sukhpreetsingh04/Android-JetPack-Compose-Course

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 

Repository files navigation

πŸ“± Android Jetpack Compose Course Notes


πŸ“Œ 1. Introduction to Android Development

Android development is the process of building applications (apps) for devices running the Android Operating System (OS).

  • Android apps are packaged as APK (Android Package) files

  • APK contains:

    • Code
    • Resources
    • Assets

πŸ‘‰ Developers upload APKs to the Google Play Store for distribution.


πŸ“¦ 2. Android SDK (Software Development Kit)

The Android SDK is a collection of tools required to build Android applications.

Key Points:

  • Provides APIs, libraries, and debugging tools
  • Helps in building, testing, and managing apps
  • Fully supported by Google and the developer community

🎯 3. Course Learning Objectives

In this course, we will learn:

  1. Kotlin Programming Language
  2. Android Studio (IDE)
  3. Android Ecosystem
  4. Core Android Components
  5. Building Real Android Applications
  6. Publishing Apps on Play Store

🎨 4. Jetpack Compose

Jetpack Compose is a modern toolkit for building native Android UI.

Features:

  • Less code
  • Powerful tools
  • Intuitive Kotlin APIs

Key Idea:

πŸ‘‰ UI is created using @Composable functions in Kotlin πŸ‘‰ No need for XML layouts


πŸ’» 5. Kotlin Programming Language

Kotlin is a statically typed, open-source programming language.

Features:

  • Supports OOP + Functional Programming
  • Runs on JVM (Java Virtual Machine)
  • Interoperable with Java

Syntax:

Similar to Java, C#, and Scala


βš–οΈ 6. Static vs Dynamic Languages

  • Static Language: Variable type is determined at compile time
  • Dynamic Language: Variable type is determined at runtime

πŸ”„ 7. Kotlin Overview

  • Fully interoperable with Java
  • Easy conversion between Java ↔ Kotlin
  • Built-in Java-to-Kotlin converter in Android Studio

Advantages:

  • Less code
  • Faster development
  • Clean and readable syntax
  • Supports Web, Desktop, and Android development

🧠 8. Basic Programming Concepts

  • Package: Organizes related classes
  • Class: Blueprint for objects
  • Object: Instance of a class (contains properties + functions)
  • OOP: Programming based on objects and data
  • Function: Reusable block of code
  • Parameter/Argument: Value passed to a function

β˜• 9. JDK, JRE, JVM

  • JDK: Development tools
  • JRE: Runtime environment
  • JVM: Executes Java/Kotlin programs

🧩 10. Jetpack Compose Fundamentals

πŸ”Ή Layouts

Used to arrange UI components:

  • Row β†’ Horizontal layout
  • Column β†’ Vertical layout
  • Box β†’ Stack layout (overlapping elements)

πŸ”Ή Arrangement & Alignment

πŸ‘‰ Main Direction = Arrangement πŸ‘‰ Cross Direction = Alignment

Row:

  • horizontalArrangement
  • verticalAlignment

Column:

  • verticalArrangement
  • horizontalAlignment

πŸ“ 11. Row Layout Properties

Horizontal Arrangement:

  • Start
  • End
  • Center
  • SpaceBetween
  • SpaceAround
  • SpaceEvenly

Vertical Alignment:

  • Top
  • CenterVertically
  • Bottom

πŸ“ 12. Column Layout Properties

Vertical Arrangement:

  • Top
  • Bottom
  • Center
  • SpaceBetween
  • SpaceAround
  • SpaceEvenly

Horizontal Alignment:

  • Start
  • CenterHorizontally
  • End

βž– 13. Spacer

Spacer is used to create empty space between UI components.

Types:

  • Fixed space β†’ width(), height(), size()
  • Flexible space β†’ weight()

Usage:

  • Add spacing between elements
  • Push components apart
  • Control layout spacing

πŸ”˜ 14. Button in Jetpack Compose

A Button is a clickable UI component used to perform actions.

Basic Syntax:

Button(onClick = { }) {
    Text("Click Me")
}

Important Properties:

  • onClick β†’ Action handler
  • modifier β†’ Layout & styling
  • colors β†’ Button colors
  • enabled β†’ Enable/disable button
  • shape β†’ Corner design
  • elevation β†’ Shadow
  • border β†’ Outline
  • content β†’ UI inside button

πŸ“ 15. TextField (User Input)

TextField is used to take input from the user.

State Management:

var text by remember { mutableStateOf("") }

Important Properties:

  • value β†’ Current text
  • onValueChange β†’ Updates text
  • label β†’ Hint text
  • modifier β†’ Layout control
  • colors β†’ Styling

πŸ”„ 16. Recomposition (Very Important)

When state changes, Compose automatically updates only the affected UI.

πŸ‘‰ No manual UI refresh required


🧱 17. Modifier System

Modifiers are used to customize UI elements.

Example:

Modifier
    .fillMaxWidth()
    .padding(16.dp)
    .background(Color.Gray)

πŸ‘‰ Modifiers can be chained together


πŸ–ΌοΈ 18. Image in Compose

Used to display images from different sources:

  • Drawable resources
  • Bitmap
  • Painter
  • URL (using libraries like Coil)

Important Properties:

  • painter
  • contentDescription
  • modifier
  • contentScale
  • alignment

β˜‘οΈ 19. CheckBox

A CheckBox is a two-state component:

  • Checked
  • Unchecked

Used for selections and user input.


πŸ“Œ 20. Switch

A Switch in Jetpack Compose is a UI component used to toggle between two states β€” ON and OFF. It is commonly used in settings screens for enabling or disabling features.

It works using a boolean state (true or false) and updates through the onCheckedChange callback when the user interacts with it.


🧠 21. Stateful vs Stateless Composables

  • Stateful: Manages its own state
  • Stateless: Receives state from outside

πŸ“Œ 22. DropdownMenu

DropdownMenu is used in Jetpack Compose to display a list of selectable menu items in a popup menu.

Properties of DropdownMenu

  • expanded β†’ Controls whether the menu is visible or hidden.
  • onDismissRequest β†’ Called when the menu should close (outside click/back press).
  • modifier β†’ Used to style or position the menu.
  • offset β†’ Changes the menu position relative to its anchor.
  • properties β†’ Controls additional popup behavior.

πŸ“Œ 23. DropdownMenuItem

DropdownMenuItem represents a single selectable option inside a DropdownMenu.

Properties of DropdownMenuItem

  • text β†’ Displays the content/text of the item.
  • onClick β†’ Executes when the item is selected.
  • leadingIcon β†’ Adds an icon at the start.
  • trailingIcon β†’ Adds an icon at the end.
  • enabled β†’ Enables or disables item selection.
  • colors β†’ Customizes item colors.
  • contentPadding β†’ Adjusts spacing inside the item.

24. Toast Message

A Toast Message is a small popup message used to show short feedback to the user. It appears for a short time and disappears automatically without user action.

Properties of Toast Message

  • context -> Defines where the Toast will be shown from.
  • "message" -> The text that is displayed inside the Toast.
  • "Duration" -> Defines how long the Toast will be visible.
  • show() -> Displays the Toast message on the screen.

25. Snackbar Message

A Snackbar Message is a message shown at the bottom of the screen to give feedback to the user. It can also include an action button such as Undo, Retry, or Dismiss.

Properties of Snackbar Message

  • snackbarHostState -> Controls and manages the Snackbar message.
  • SnackbarHost -> Defines the place where the Snackbar will be displayed.
  • message -> The text displayed inside the Snackbar.
  • actionLabel -> Adds an action button inside the Snackbar.
  • "duration" -> Defines how long the Snackbar will stay visible.
  • showSnackbar() -> Displays the Snackbar message.
  • "CoroutineScope" -> Required because showSnackbar() is a suspend function.

26. Difference between Toast Message and Snackbar Message

Toast Message Snackbar Message
Shows a small popup message Shows a message at the bottom of the screen
Cannot have action button Can have action button
Automatically disappears Can disappear or wait for user action
Simple to use Requires Scaffold, SnackbarHostState, and CoroutineScope
Good for small feedback Good for important feedback
Less interactive More interactive
Example: β€œCopied” Example: β€œTask deleted β€” Undo”