Challenge - 5 Problems
Modifier Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2: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)
)Attempts:
2 left
💡 Hint
Padding reduces the space available inside the size modifier.
✗ Incorrect
The size modifier sets the total size to 100.dp. Padding of 20.dp on all sides adds space outside the size, so the total size becomes 140.dp by 140.dp. The blue background is applied after padding, so the visible blue box is 100.dp by 100.dp.
❓ ui_behavior
intermediate2: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) )
Attempts:
2 left
💡 Hint
Modifier order affects layout and interaction.
✗ Incorrect
The clickable modifier makes the Text respond to taps and prints "Tapped". Padding adds space around the Text content. Both work together as expected.
❓ lifecycle
advanced2: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)
)Attempts:
2 left
💡 Hint
Modifier order affects layout and interaction area.
✗ Incorrect
Clickable is applied last, so it covers the entire Box area including padding and size. The tap should be detected and print "Clicked".
📝 Syntax
advanced2: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.
Attempts:
2 left
💡 Hint
Modifiers are chained with dots and parentheses.
✗ Incorrect
Option B correctly chains padding and clickable modifiers. Option B applies clickable first, which is valid but changes hit area. Options C and D have syntax errors.
🔧 Debug
expert2: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") }
)Attempts:
2 left
💡 Hint
Background modifier does not block clicks by itself.
✗ Incorrect
Background does not block clicks. Clickable is last, so it covers the full Box area and should respond. If clicks are not detected, the problem is likely outside this code snippet.