SlideShare a Scribd company logo
2
Modifiers
Modifiers allow you to decorate or augment a
composable. Modifiers let you do these sorts of things:
• Change the composable's size, layout, behavior, and
appearance
• Add information, like accessibility labels
• Process user input
• Add high-level interactions, like making an element
clickable, scrollable, draggable, or zoomable
3
Modifiers (Cont.)
4
Modifiers can be used modify certain aspects of a Composable. To set
them, a Composable needs to accept a modifier as a parameter.
Modifiers are standard Kotlin objects. Create a modifier by calling one
of the Modifier class functions. You can chain these functions together
to compose them:
Example of Basic Modifiers
5
Example of Basic Modifiers (Cont.)
6
Example of Basic Modifiers (Cont.)
7
In the previous code, notice different modifier
functions used together:
• clickable makes a composable react to user
input and shows a ripple.
• padding puts space around an element.
• fillMaxWidth makes the composable fill the
maximum width given to it from its parent.
• size() specifies an element's preferred width and
height.
Order of Modifiers
Matters
The order of modifier functions is significant. Since each
function makes changes to the Modifier returned by the
previous function, the sequence affects the final result.
8
Built-in Modifiers
9
Jetpack Compose provides a list of built-in modifiers to help you
decorate or augment a composable. Some modifiers such as padding,
clickable, and fillMaxWidth have already been introduced. Here’s a list
of other common modifiers:
• Size
• Offset
• MatchParentSize in Box
• Weight in Row and Column
By default, layouts provided in Compose wrap their
children. However, you can set a size by using the
size modifier:
Size
10
In this example, even with the parent height set to
100.dp, the height of the Image will be 150.dp, as
the requiredSize modifier takes precedence.
Size (Cont.)
11
Offset
To position a layout relative to its original position, add
the offset modifier and set the offset in the x and y axis.
Offsets can be positive as well as non-positive. The
difference between padding and offset is that adding an
offset to a composable does not change its measurements
12
Offset (Cont.)
The offset modifier is applied horizontally according to the
layout direction. In a left-to-right context, a positive offset
shifts the element to the right, while in a right-to-left
context, it shifts the element to the left. If you need to set
an offset without considering layout direction, see the
absoluteOffset modifier, in which a positive offset value
always shifts the element to the right.
13
matchParentSize in Box
14
If you want a child layout to be the same size as a parent Box without
affecting the Box size, use the matchParentSize modifier. Note that
matchParentSize is only available within a Box scope, meaning that it
only applies to direct children of Box composables.
In the example below, the child Spacer takes its size from its parent
Box, which in turn takes its size from the biggest children, ArtistCard in
this case.
Here is the result :
matchParentSize in Box (Cont.)
15
matchParentSize in Box (Cont.)
16
If fillMaxSize were used instead of matchParentSize, the Spacer would
take all the available space allowed to the parent, in turn causing the
parent to expand and fill all the available space.
weight in Row and
Column
You can set a composable size to be flexible within its
parent using the weight Modifier that is only available in
RowScope, and ColumnScope.
Let’s take a Row that contains two Box composables. The
first box is given twice the weight of the second, so it's
given twice the width.
17
weight in Row and
Column (Cont.)
Since the Row is 210.dp
wide, the first Box is 140.dp
wide, and the second is
70.dp:
18
weight in Row and
Column (Cont.)
Here is the result of using weight in row and column on
two elements:
19
Image Card
20
The Card composable is a surface that can be used to present content
and actions focused on a single topic.
When it comes to displaying a Card composable, we can do so by using
the provided composable function, along with the minimal required
arguments. The Card only has a single required argument, which is the
content argument – this is used as the body of the Card.
Here is a basic example of a card:
Here is the result :
Image Card (Cont.)
21
Styling the Card
Once we’ve composed a Card, it might be the case that
we’re going to want to apply some styling to override the
default which is provided by the theme of our application.
In these cases, the Card composable offers several
arguments which can be used to control the look and feel.
22
Setting the Shape
23
We can set the shape to be used for the card by using the shape
argument and providing a Shape reference. If not provided then this
will default to the medium shape from the theme of our application.
We can set the color to be used for the background
of the card by using the backgroundColor argument
and providing a Color reference. If not provided
then this will default to the surface color from the
theme of our application.
Setting the Background Color
24
Setting the Content
Color
We can set the color to be used for the background of the
card by using the contentColor argument and providing a
Color reference. If not provided then this will default to a
color calculated from the background color of the card.
25
Adding a Border
26
We can add a border to the card by using the border argument and
providing a dp value. If not provided then this will default to null and
no border will be applied to the card.
We can apply elevation to the card by using the
elevation argument and providing a BorderStroke
reference. If not provided then this will default to
the value of 1 dp.
Applying Elevation to the Card
27
Mobile Programming - 4 Modifiers and Image Card

More Related Content

Similar to Mobile Programming - 4 Modifiers and Image Card

Breakeven cv02
Breakeven cv02Breakeven cv02
w05_Grader_h1_Airline_LastFirst (solution)
w05_Grader_h1_Airline_LastFirst (solution)w05_Grader_h1_Airline_LastFirst (solution)
w05_Grader_h1_Airline_LastFirst (solution)
JackCandtona
 
computer applications in business unit 3
computer applications in business unit 3computer applications in business unit 3
computer applications in business unit 3
Dr T.Sivakami
 
Study on grading the develop pattern in CAD.
Study on grading the develop pattern in CAD.Study on grading the develop pattern in CAD.
Study on grading the develop pattern in CAD.
NazmulHasanAnan
 
CFM Challenge - Course Project
CFM Challenge - Course ProjectCFM Challenge - Course Project
CFM Challenge - Course Project
KhalilBergaoui
 
Microsoft Excel Tutorial
Microsoft Excel TutorialMicrosoft Excel Tutorial
Microsoft Excel Tutorial
Kristine Tiongco-Rimpa
 
Building Responsive Layouts
Building Responsive LayoutsBuilding Responsive Layouts
Building Responsive Layouts
Zoe Gillenwater
 
Geographical Information System (GIS) Georeferencing and Digitization, Bihar ...
Geographical Information System (GIS) Georeferencing and Digitization, Bihar ...Geographical Information System (GIS) Georeferencing and Digitization, Bihar ...
Geographical Information System (GIS) Georeferencing and Digitization, Bihar ...
Kamlesh Kumar
 
PHYS 221Lab 1 - Acceleration Due to GravityPlease work in g.docx
PHYS 221Lab 1 - Acceleration Due to GravityPlease work in g.docxPHYS 221Lab 1 - Acceleration Due to GravityPlease work in g.docx
PHYS 221Lab 1 - Acceleration Due to GravityPlease work in g.docx
mattjtoni51554
 
Cad me2155-lab-manual
Cad me2155-lab-manualCad me2155-lab-manual
Cad me2155-lab-manual
Nandhini Disanth
 
Compensator Design and parameters modification using Bode plot and root locus
Compensator Design and parameters modification using Bode plot and root locusCompensator Design and parameters modification using Bode plot and root locus
Compensator Design and parameters modification using Bode plot and root locus
MIbrar4
 
Data Transformation
Data TransformationData Transformation
Data Transformation
ArmanArafatAnik
 
Robotic iAssembly
Robotic iAssemblyRobotic iAssembly
Robotic iAssembly
Brian Halicki
 
Layout manager
Layout managerLayout manager
R Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar PlotsR Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar Plots
Rsquared Academy
 
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Erdi Karaçal
 
Coord transform 082014
Coord transform 082014Coord transform 082014
Coord transform 082014
PramodPandit9
 
DataTables
DataTablesDataTables
DataTables
SourabhChoraria2
 
4.3 Fitting Linear Models to Data
4.3 Fitting Linear Models to Data4.3 Fitting Linear Models to Data
4.3 Fitting Linear Models to Data
smiller5
 

Similar to Mobile Programming - 4 Modifiers and Image Card (20)

Breakeven cv02
Breakeven cv02Breakeven cv02
Breakeven cv02
 
w05_Grader_h1_Airline_LastFirst (solution)
w05_Grader_h1_Airline_LastFirst (solution)w05_Grader_h1_Airline_LastFirst (solution)
w05_Grader_h1_Airline_LastFirst (solution)
 
computer applications in business unit 3
computer applications in business unit 3computer applications in business unit 3
computer applications in business unit 3
 
Study on grading the develop pattern in CAD.
Study on grading the develop pattern in CAD.Study on grading the develop pattern in CAD.
Study on grading the develop pattern in CAD.
 
CFM Challenge - Course Project
CFM Challenge - Course ProjectCFM Challenge - Course Project
CFM Challenge - Course Project
 
Microsoft Excel Tutorial
Microsoft Excel TutorialMicrosoft Excel Tutorial
Microsoft Excel Tutorial
 
Building Responsive Layouts
Building Responsive LayoutsBuilding Responsive Layouts
Building Responsive Layouts
 
Geographical Information System (GIS) Georeferencing and Digitization, Bihar ...
Geographical Information System (GIS) Georeferencing and Digitization, Bihar ...Geographical Information System (GIS) Georeferencing and Digitization, Bihar ...
Geographical Information System (GIS) Georeferencing and Digitization, Bihar ...
 
PHYS 221Lab 1 - Acceleration Due to GravityPlease work in g.docx
PHYS 221Lab 1 - Acceleration Due to GravityPlease work in g.docxPHYS 221Lab 1 - Acceleration Due to GravityPlease work in g.docx
PHYS 221Lab 1 - Acceleration Due to GravityPlease work in g.docx
 
Cad me2155-lab-manual
Cad me2155-lab-manualCad me2155-lab-manual
Cad me2155-lab-manual
 
Compensator Design and parameters modification using Bode plot and root locus
Compensator Design and parameters modification using Bode plot and root locusCompensator Design and parameters modification using Bode plot and root locus
Compensator Design and parameters modification using Bode plot and root locus
 
Data Transformation
Data TransformationData Transformation
Data Transformation
 
Robotic iAssembly
Robotic iAssemblyRobotic iAssembly
Robotic iAssembly
 
Layout manager
Layout managerLayout manager
Layout manager
 
R Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar PlotsR Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar Plots
 
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...Me 443   4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
Me 443 4 plotting curves Erdi Karaçal Mechanical Engineer University of Gaz...
 
Coord transform 082014
Coord transform 082014Coord transform 082014
Coord transform 082014
 
DataTables
DataTablesDataTables
DataTables
 
Version numbering system
Version numbering systemVersion numbering system
Version numbering system
 
4.3 Fitting Linear Models to Data
4.3 Fitting Linear Models to Data4.3 Fitting Linear Models to Data
4.3 Fitting Linear Models to Data
 

More from AndiNurkholis1

Mobile Programming - 10 Firebase
Mobile Programming - 10 FirebaseMobile Programming - 10 Firebase
Mobile Programming - 10 Firebase
AndiNurkholis1
 
Mobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
Mobile Programming - 9 Profile UI, Navigation Basic and Splash ScreenMobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
Mobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
AndiNurkholis1
 
Mobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
Mobile Programming - 8 Progress Bar, Draggable Music Knob, TimerMobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
Mobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
AndiNurkholis1
 
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple Animations
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple AnimationsMobile Programming - 7 Side Effects, Effect Handlers, and Simple Animations
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple Animations
AndiNurkholis1
 
Mobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
Mobile Programming - 6 Textfields, Button, Showing Snackbars and ListsMobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
Mobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
AndiNurkholis1
 
Mobile Programming - 5 Stylling Text and State
Mobile Programming - 5 Stylling Text and StateMobile Programming - 5 Stylling Text and State
Mobile Programming - 5 Stylling Text and State
AndiNurkholis1
 
Mobile Programming - 3 Rows, Column and Basic Sizing
Mobile Programming - 3 Rows, Column and Basic SizingMobile Programming - 3 Rows, Column and Basic Sizing
Mobile Programming - 3 Rows, Column and Basic Sizing
AndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Struktur Data
Algoritma dan Struktur Data (Python) - Struktur DataAlgoritma dan Struktur Data (Python) - Struktur Data
Algoritma dan Struktur Data (Python) - Struktur Data
AndiNurkholis1
 
Mobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack ComposeMobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack Compose
AndiNurkholis1
 
Mobile Programming - 1 Introduction
Mobile Programming - 1 IntroductionMobile Programming - 1 Introduction
Mobile Programming - 1 Introduction
AndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Perulangan
Algoritma dan Struktur Data (Python) - PerulanganAlgoritma dan Struktur Data (Python) - Perulangan
Algoritma dan Struktur Data (Python) - Perulangan
AndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Percabangan
Algoritma dan Struktur Data (Python) - PercabanganAlgoritma dan Struktur Data (Python) - Percabangan
Algoritma dan Struktur Data (Python) - Percabangan
AndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Struktur I/O
Algoritma dan Struktur Data (Python) - Struktur I/OAlgoritma dan Struktur Data (Python) - Struktur I/O
Algoritma dan Struktur Data (Python) - Struktur I/O
AndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Notasi Algoritmik
Algoritma dan Struktur Data (Python) - Notasi AlgoritmikAlgoritma dan Struktur Data (Python) - Notasi Algoritmik
Algoritma dan Struktur Data (Python) - Notasi Algoritmik
AndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Pengantar Algoritma
Algoritma dan Struktur Data (Python) - Pengantar AlgoritmaAlgoritma dan Struktur Data (Python) - Pengantar Algoritma
Algoritma dan Struktur Data (Python) - Pengantar Algoritma
AndiNurkholis1
 
Algorithm and Data Structure - Binary Search
Algorithm and Data Structure - Binary SearchAlgorithm and Data Structure - Binary Search
Algorithm and Data Structure - Binary Search
AndiNurkholis1
 
Algorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear SearchAlgorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear Search
AndiNurkholis1
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - Queue
AndiNurkholis1
 
Algorithm and Data Structure - Stack
Algorithm and Data Structure - StackAlgorithm and Data Structure - Stack
Algorithm and Data Structure - Stack
AndiNurkholis1
 
Algorithm and Data Structure - Modular Programming
Algorithm and Data Structure - Modular ProgrammingAlgorithm and Data Structure - Modular Programming
Algorithm and Data Structure - Modular Programming
AndiNurkholis1
 

More from AndiNurkholis1 (20)

Mobile Programming - 10 Firebase
Mobile Programming - 10 FirebaseMobile Programming - 10 Firebase
Mobile Programming - 10 Firebase
 
Mobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
Mobile Programming - 9 Profile UI, Navigation Basic and Splash ScreenMobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
Mobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
 
Mobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
Mobile Programming - 8 Progress Bar, Draggable Music Knob, TimerMobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
Mobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
 
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple Animations
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple AnimationsMobile Programming - 7 Side Effects, Effect Handlers, and Simple Animations
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple Animations
 
Mobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
Mobile Programming - 6 Textfields, Button, Showing Snackbars and ListsMobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
Mobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
 
Mobile Programming - 5 Stylling Text and State
Mobile Programming - 5 Stylling Text and StateMobile Programming - 5 Stylling Text and State
Mobile Programming - 5 Stylling Text and State
 
Mobile Programming - 3 Rows, Column and Basic Sizing
Mobile Programming - 3 Rows, Column and Basic SizingMobile Programming - 3 Rows, Column and Basic Sizing
Mobile Programming - 3 Rows, Column and Basic Sizing
 
Algoritma dan Struktur Data (Python) - Struktur Data
Algoritma dan Struktur Data (Python) - Struktur DataAlgoritma dan Struktur Data (Python) - Struktur Data
Algoritma dan Struktur Data (Python) - Struktur Data
 
Mobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack ComposeMobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack Compose
 
Mobile Programming - 1 Introduction
Mobile Programming - 1 IntroductionMobile Programming - 1 Introduction
Mobile Programming - 1 Introduction
 
Algoritma dan Struktur Data (Python) - Perulangan
Algoritma dan Struktur Data (Python) - PerulanganAlgoritma dan Struktur Data (Python) - Perulangan
Algoritma dan Struktur Data (Python) - Perulangan
 
Algoritma dan Struktur Data (Python) - Percabangan
Algoritma dan Struktur Data (Python) - PercabanganAlgoritma dan Struktur Data (Python) - Percabangan
Algoritma dan Struktur Data (Python) - Percabangan
 
Algoritma dan Struktur Data (Python) - Struktur I/O
Algoritma dan Struktur Data (Python) - Struktur I/OAlgoritma dan Struktur Data (Python) - Struktur I/O
Algoritma dan Struktur Data (Python) - Struktur I/O
 
Algoritma dan Struktur Data (Python) - Notasi Algoritmik
Algoritma dan Struktur Data (Python) - Notasi AlgoritmikAlgoritma dan Struktur Data (Python) - Notasi Algoritmik
Algoritma dan Struktur Data (Python) - Notasi Algoritmik
 
Algoritma dan Struktur Data (Python) - Pengantar Algoritma
Algoritma dan Struktur Data (Python) - Pengantar AlgoritmaAlgoritma dan Struktur Data (Python) - Pengantar Algoritma
Algoritma dan Struktur Data (Python) - Pengantar Algoritma
 
Algorithm and Data Structure - Binary Search
Algorithm and Data Structure - Binary SearchAlgorithm and Data Structure - Binary Search
Algorithm and Data Structure - Binary Search
 
Algorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear SearchAlgorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear Search
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - Queue
 
Algorithm and Data Structure - Stack
Algorithm and Data Structure - StackAlgorithm and Data Structure - Stack
Algorithm and Data Structure - Stack
 
Algorithm and Data Structure - Modular Programming
Algorithm and Data Structure - Modular ProgrammingAlgorithm and Data Structure - Modular Programming
Algorithm and Data Structure - Modular Programming
 

Recently uploaded

Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 

Recently uploaded (20)

Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 

Mobile Programming - 4 Modifiers and Image Card

  • 1.
  • 2. 2
  • 3. Modifiers Modifiers allow you to decorate or augment a composable. Modifiers let you do these sorts of things: • Change the composable's size, layout, behavior, and appearance • Add information, like accessibility labels • Process user input • Add high-level interactions, like making an element clickable, scrollable, draggable, or zoomable 3
  • 4. Modifiers (Cont.) 4 Modifiers can be used modify certain aspects of a Composable. To set them, a Composable needs to accept a modifier as a parameter. Modifiers are standard Kotlin objects. Create a modifier by calling one of the Modifier class functions. You can chain these functions together to compose them:
  • 5. Example of Basic Modifiers 5
  • 6. Example of Basic Modifiers (Cont.) 6
  • 7. Example of Basic Modifiers (Cont.) 7 In the previous code, notice different modifier functions used together: • clickable makes a composable react to user input and shows a ripple. • padding puts space around an element. • fillMaxWidth makes the composable fill the maximum width given to it from its parent. • size() specifies an element's preferred width and height.
  • 8. Order of Modifiers Matters The order of modifier functions is significant. Since each function makes changes to the Modifier returned by the previous function, the sequence affects the final result. 8
  • 9. Built-in Modifiers 9 Jetpack Compose provides a list of built-in modifiers to help you decorate or augment a composable. Some modifiers such as padding, clickable, and fillMaxWidth have already been introduced. Here’s a list of other common modifiers: • Size • Offset • MatchParentSize in Box • Weight in Row and Column
  • 10. By default, layouts provided in Compose wrap their children. However, you can set a size by using the size modifier: Size 10
  • 11. In this example, even with the parent height set to 100.dp, the height of the Image will be 150.dp, as the requiredSize modifier takes precedence. Size (Cont.) 11
  • 12. Offset To position a layout relative to its original position, add the offset modifier and set the offset in the x and y axis. Offsets can be positive as well as non-positive. The difference between padding and offset is that adding an offset to a composable does not change its measurements 12
  • 13. Offset (Cont.) The offset modifier is applied horizontally according to the layout direction. In a left-to-right context, a positive offset shifts the element to the right, while in a right-to-left context, it shifts the element to the left. If you need to set an offset without considering layout direction, see the absoluteOffset modifier, in which a positive offset value always shifts the element to the right. 13
  • 14. matchParentSize in Box 14 If you want a child layout to be the same size as a parent Box without affecting the Box size, use the matchParentSize modifier. Note that matchParentSize is only available within a Box scope, meaning that it only applies to direct children of Box composables. In the example below, the child Spacer takes its size from its parent Box, which in turn takes its size from the biggest children, ArtistCard in this case.
  • 15. Here is the result : matchParentSize in Box (Cont.) 15
  • 16. matchParentSize in Box (Cont.) 16 If fillMaxSize were used instead of matchParentSize, the Spacer would take all the available space allowed to the parent, in turn causing the parent to expand and fill all the available space.
  • 17. weight in Row and Column You can set a composable size to be flexible within its parent using the weight Modifier that is only available in RowScope, and ColumnScope. Let’s take a Row that contains two Box composables. The first box is given twice the weight of the second, so it's given twice the width. 17
  • 18. weight in Row and Column (Cont.) Since the Row is 210.dp wide, the first Box is 140.dp wide, and the second is 70.dp: 18
  • 19. weight in Row and Column (Cont.) Here is the result of using weight in row and column on two elements: 19
  • 20. Image Card 20 The Card composable is a surface that can be used to present content and actions focused on a single topic. When it comes to displaying a Card composable, we can do so by using the provided composable function, along with the minimal required arguments. The Card only has a single required argument, which is the content argument – this is used as the body of the Card.
  • 21. Here is a basic example of a card: Here is the result : Image Card (Cont.) 21
  • 22. Styling the Card Once we’ve composed a Card, it might be the case that we’re going to want to apply some styling to override the default which is provided by the theme of our application. In these cases, the Card composable offers several arguments which can be used to control the look and feel. 22
  • 23. Setting the Shape 23 We can set the shape to be used for the card by using the shape argument and providing a Shape reference. If not provided then this will default to the medium shape from the theme of our application.
  • 24. We can set the color to be used for the background of the card by using the backgroundColor argument and providing a Color reference. If not provided then this will default to the surface color from the theme of our application. Setting the Background Color 24
  • 25. Setting the Content Color We can set the color to be used for the background of the card by using the contentColor argument and providing a Color reference. If not provided then this will default to a color calculated from the background color of the card. 25
  • 26. Adding a Border 26 We can add a border to the card by using the border argument and providing a dp value. If not provided then this will default to null and no border will be applied to the card.
  • 27. We can apply elevation to the card by using the elevation argument and providing a BorderStroke reference. If not provided then this will default to the value of 1 dp. Applying Elevation to the Card 27