SlideShare a Scribd company logo
Hold On.
It will start soon :)
Become an Android Developer
Session - 2: Layouts, Views and Project Demo
24/12/2021
12:00 PM - 1:00PM IST
GDSC DYPIU
Host: Atharv Karbhari
Topics:
● Lists : Mutable vs Immutable
● Conditional Statements
● Project Demo: Simple Button App
● with and when Keywords
● Views and Binding
● Project Demo: Tip Calculator App
● Useful functions
Lists: Mutable Vs Immutable:
Lists: A linear data structure used to store data.
Syntax:
<Keyword> <variable name>:List<Data type of item> = listOf(<i1>,<i2>,<i3>,....)
Usage: (Immutable Lists)
val list1:List<Int> = listOf(1,2,3,4,5,6)
val list2:List<String> = listOf(“a”,”b”,”c”)
Methods/Functions: (More: https://kotlinlang.org/docs/list-operations.html)
.size -> Int
l1[index]
l1.first()
l1.last()
l1.indexOf(element)
l1.subList(0,3)
l1.reversed() -> List
l1.contains(element) -> Boolean
l1.sorted() -> List
Lists: Mutable Vs Immutable:
Lists: A linear data structure used to store data.
Syntax:
<Keyword> <variable name>:MutableList<Data type of item> = mutableListOf(<i1>,<i2>,<i3>,....)
Usage: (Mutable Lists)
val l1:MutableList<Int> = mutableListOf(1,2,3,4)
Methods/Functions: (More: https://kotlinlang.org/docs/list-operations.html)
l1.size -> Int
l1.first()
l1.last()
l1.addAll()
l1.add(3) -> Boolean (false if could not add)
l1.remove(3) -> Boolean (false if doesn’t exist)
l1.reversed()
l1.contains(3)
l1.sorted()
l1.removeAt(2)
l1.isEmpty() -> Boolean
l1.clear()
Conditional Statement
Usage:
if (expression){
body
}
else{
body
}
“with” vs “when”
Usage:
with (object){
property1 // Equivalent of object.property1
property2 // Equivalent of object.property2
print(property3) // print(object.property3)
}
“with” vs “when”
Usage:
1.
when (object){
value1 -> <statement 1>
value2 -> <statement 2>
value3 -> <statement 3>
value4 -> <statement 4>
}
2.
val obj1 = value
when {
value1 > 10 -> <statement 1>
value2 == 5 -> <statement 2>
value3 <= 5 -> <statement 3>
value4 + 1 ==10 -> <statement 4>
}
Project Demo - 1
Button App
Layout Design
Integrate XML
Adding Vector and Image Assets
Layout(Padding Vs Margin)
Padding
Margin
1. Padding: Distance between View content and
View Body
2. Margin: Distance between View Body and Parent
View
Project Demo - 2
Tip Calculator
View Binding Vs findViewById()
App/build.gradle:
buildFeatures {
viewBinding true
}
MainActivity.kt:
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
}
Usage:
binding.view1 // same as
findViewById<View>(R.id.view1)
binding.view2 // same as
findViewById<View>(R.id.view2)
View Binding Vs findViewById()
Cheatsheet / Summary:
View Binding: One reference to all views having id
findViewById(): Add a reference to a view
Important Tags:
android:text="This text"
android:layout_below="@+id/another_view"
android:padding="40dp"
android:layout_margin="40dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
wrap_content: Match height/width according to content
match_parent: Match height/width/property of parent view
Thank You!!
Host: Atharv Karbhari
LinkedIn
Github
Hackerrank

More Related Content

PDF
Session 1 android study jam GDSC DYPIU
PDF
Session 3 android study jam
PPTX
Understanding angular meteor
PDF
JSAnkara Swift v React Native
PDF
Swift ui userinput
PPTX
Dot net technology
PDF
Deep Dive Into Repository - Android Architecture Components
PDF
Dependency injection crash course
Session 1 android study jam GDSC DYPIU
Session 3 android study jam
Understanding angular meteor
JSAnkara Swift v React Native
Swift ui userinput
Dot net technology
Deep Dive Into Repository - Android Architecture Components
Dependency injection crash course

What's hot (11)

PDF
05 binding and action
PPTX
Knockout extender
PDF
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
PPTX
Why magic
PPTX
Synapse india dotnet development overloading operater part 4
PDF
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
PDF
SFScon19 - Luca Romano Simone Vianello - ORM and RDBMS, how to make them work...
PPTX
Goa tutorial
PDF
Reduce your Angular state options with NGXS
PDF
Fetch data from form
PDF
Fragments In Android
05 binding and action
Knockout extender
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Why magic
Synapse india dotnet development overloading operater part 4
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
SFScon19 - Luca Romano Simone Vianello - ORM and RDBMS, how to make them work...
Goa tutorial
Reduce your Angular state options with NGXS
Fetch data from form
Fragments In Android
Ad

Similar to Session 2 android study jam (20)

PPTX
Specification Scala DSL for Mobile Application
PPT
Object Oriented Software Development, using c# programming language
PDF
ANGULARJS.pdf
PDF
Android L01 - Warm Up
PDF
Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...
PDF
.NET Portfolio
PDF
Advanced Swift Generics
PDF
02 objective-c session 2
DOCX
D2 k word_format
PPTX
Angular2 + rxjs
PDF
How to become an Android dev starting from iOS (and vice versa)
PPTX
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
PPTX
Angularjs Basics
PDF
Architecture for scalable Angular applications
PDF
07_UIAndroid.pdf
PDF
Android Jetpack - Google IO Extended Singapore 2018
PDF
Green dao
PDF
Modern frontend development with VueJs
PPTX
Angular1x and Angular 2 for Beginners
PDF
From Legacy to Hexagonal (An Unexpected Android Journey)
Specification Scala DSL for Mobile Application
Object Oriented Software Development, using c# programming language
ANGULARJS.pdf
Android L01 - Warm Up
Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...
.NET Portfolio
Advanced Swift Generics
02 objective-c session 2
D2 k word_format
Angular2 + rxjs
How to become an Android dev starting from iOS (and vice versa)
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Angularjs Basics
Architecture for scalable Angular applications
07_UIAndroid.pdf
Android Jetpack - Google IO Extended Singapore 2018
Green dao
Modern frontend development with VueJs
Angular1x and Angular 2 for Beginners
From Legacy to Hexagonal (An Unexpected Android Journey)
Ad

Recently uploaded (20)

PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPT
Introduction Database Management System for Course Database
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
System and Network Administration Chapter 2
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Introduction to Artificial Intelligence
How to Migrate SBCGlobal Email to Yahoo Easily
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Softaken Excel to vCard Converter Software.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Introduction Database Management System for Course Database
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PTS Company Brochure 2025 (1).pdf.......
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Understanding Forklifts - TECH EHS Solution
Design an Analysis of Algorithms I-SECS-1021-03
Odoo Companies in India – Driving Business Transformation.pdf
System and Network Administration Chapter 2
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Upgrade and Innovation Strategies for SAP ERP Customers
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Introduction to Artificial Intelligence

Session 2 android study jam

  • 1. Hold On. It will start soon :)
  • 2. Become an Android Developer Session - 2: Layouts, Views and Project Demo 24/12/2021 12:00 PM - 1:00PM IST GDSC DYPIU Host: Atharv Karbhari
  • 3. Topics: ● Lists : Mutable vs Immutable ● Conditional Statements ● Project Demo: Simple Button App ● with and when Keywords ● Views and Binding ● Project Demo: Tip Calculator App ● Useful functions
  • 4. Lists: Mutable Vs Immutable: Lists: A linear data structure used to store data. Syntax: <Keyword> <variable name>:List<Data type of item> = listOf(<i1>,<i2>,<i3>,....) Usage: (Immutable Lists) val list1:List<Int> = listOf(1,2,3,4,5,6) val list2:List<String> = listOf(“a”,”b”,”c”) Methods/Functions: (More: https://kotlinlang.org/docs/list-operations.html) .size -> Int l1[index] l1.first() l1.last() l1.indexOf(element) l1.subList(0,3) l1.reversed() -> List l1.contains(element) -> Boolean l1.sorted() -> List
  • 5. Lists: Mutable Vs Immutable: Lists: A linear data structure used to store data. Syntax: <Keyword> <variable name>:MutableList<Data type of item> = mutableListOf(<i1>,<i2>,<i3>,....) Usage: (Mutable Lists) val l1:MutableList<Int> = mutableListOf(1,2,3,4) Methods/Functions: (More: https://kotlinlang.org/docs/list-operations.html) l1.size -> Int l1.first() l1.last() l1.addAll() l1.add(3) -> Boolean (false if could not add) l1.remove(3) -> Boolean (false if doesn’t exist) l1.reversed() l1.contains(3) l1.sorted() l1.removeAt(2) l1.isEmpty() -> Boolean l1.clear()
  • 7. “with” vs “when” Usage: with (object){ property1 // Equivalent of object.property1 property2 // Equivalent of object.property2 print(property3) // print(object.property3) }
  • 8. “with” vs “when” Usage: 1. when (object){ value1 -> <statement 1> value2 -> <statement 2> value3 -> <statement 3> value4 -> <statement 4> } 2. val obj1 = value when { value1 > 10 -> <statement 1> value2 == 5 -> <statement 2> value3 <= 5 -> <statement 3> value4 + 1 ==10 -> <statement 4> }
  • 9. Project Demo - 1 Button App Layout Design Integrate XML Adding Vector and Image Assets
  • 10. Layout(Padding Vs Margin) Padding Margin 1. Padding: Distance between View content and View Body 2. Margin: Distance between View Body and Parent View
  • 11. Project Demo - 2 Tip Calculator
  • 12. View Binding Vs findViewById() App/build.gradle: buildFeatures { viewBinding true } MainActivity.kt: private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) } Usage: binding.view1 // same as findViewById<View>(R.id.view1) binding.view2 // same as findViewById<View>(R.id.view2)
  • 13. View Binding Vs findViewById() Cheatsheet / Summary: View Binding: One reference to all views having id findViewById(): Add a reference to a view Important Tags: android:text="This text" android:layout_below="@+id/another_view" android:padding="40dp" android:layout_margin="40dp" android:layout_centerVertical="true" android:layout_centerHorizontal="true" wrap_content: Match height/width according to content match_parent: Match height/width/property of parent view
  • 14. Thank You!! Host: Atharv Karbhari LinkedIn Github Hackerrank