0
0
Android Kotlinmobile~20 mins

Modifier basics (padding, size, clickable) in Android Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Modifier Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What is the visible size of the Box?
Consider this Jetpack Compose code snippet. What will be the size of the blue Box on the screen?
Android Kotlin
Box(
  modifier = Modifier
    .size(100.dp)
    .padding(20.dp)
    .background(Color.Blue)
)
A80.dp by 80.dp visible blue area after padding
B120.dp by 120.dp because padding adds outside size
C100.dp by 100.dp including padding
D60.dp by 60.dp visible blue area after padding
Attempts:
2 left
💡 Hint
Padding reduces the space available inside the size modifier.
ui_behavior
intermediate
2:00remaining
What happens when you tap the Text?
Given this code, what will happen when the user taps the Text?
Android Kotlin
Text(
  text = "Click me",
  modifier = Modifier
    .clickable { println("Tapped") }
    .padding(16.dp)
)
AText is clickable but no padding is applied
BText prints "Tapped" but padding is ignored
CText is not clickable because padding disables it
DText prints "Tapped" and has 16.dp padding around it
Attempts:
2 left
💡 Hint
Modifier order affects layout and interaction.
lifecycle
advanced
2:00remaining
Why does the clickable modifier not respond?
This code shows a Box with clickable and padding modifiers. Why does tapping the Box not trigger the clickable action?
Android Kotlin
Box(
  modifier = Modifier
    .padding(16.dp)
    .size(100.dp)
    .clickable { println("Clicked") }
    .background(Color.Red)
)
AClickable is applied last, so it works correctly and should respond
BClickable must be before padding to work properly
CClickable is after size, so it applies to a smaller area and misses taps
DClickable is after size and background, so it is overridden and disabled
Attempts:
2 left
💡 Hint
Modifier order affects layout and interaction area.
📝 Syntax
advanced
2:00remaining
Which code snippet correctly applies padding and clickable modifiers?
Select the code snippet that correctly applies 12.dp padding and makes the Text clickable.
AText("Hello", modifier = Modifier.clickable { }.padding(12.dp))
BText("Hello", modifier = Modifier.padding(12.dp).clickable { })
CText("Hello", modifier = Modifier.padding(12.dp, clickable { }))
DText("Hello", modifier = Modifier.clickable { } padding(12.dp))
Attempts:
2 left
💡 Hint
Modifiers are chained with dots and parentheses.
🔧 Debug
expert
2:00remaining
Why does this Box not respond to clicks?
This Box has clickable and background modifiers. Why does tapping it not print "Box clicked"?
Android Kotlin
Box(
  modifier = Modifier
    .background(Color.Green)
    .size(80.dp)
    .clickable { println("Box clicked") }
)
AClickable must be before size to work
BBackground does not consume clicks, so clickable should work; issue is elsewhere
CClickable is applied last, so it should work and print the message
DBackground is applied before clickable, so clickable is blocked by background
Attempts:
2 left
💡 Hint
Background modifier does not block clicks by itself.