Challenge - 5 Problems
Spacer Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
Spacer composable behavior in a Row
What will be the visual result of this code snippet in a Row layout?
Row {
Text("Start")
Spacer(modifier = Modifier.width(16.dp))
Text("End")
}Android Kotlin
Row {
Text("Start")
Spacer(modifier = Modifier.width(16.dp))
Text("End")
}Attempts:
2 left
💡 Hint
Remember Spacer adds empty space in the direction of the layout.
✗ Incorrect
In a Row, Spacer with width(16.dp) adds horizontal space between the two Text composables.
❓ ui_behavior
intermediate2:00remaining
Spacer usage in Column with height modifier
What happens when you use Spacer with Modifier.height(24.dp) inside a Column?
Column {
Text("Top")
Spacer(modifier = Modifier.height(24.dp))
Text("Bottom")
}Android Kotlin
Column {
Text("Top")
Spacer(modifier = Modifier.height(24.dp))
Text("Bottom")
}Attempts:
2 left
💡 Hint
Column arranges children vertically; height modifier affects vertical space.
✗ Incorrect
Spacer with height(24.dp) adds vertical empty space between "Top" and "Bottom" texts in a Column.
❓ lifecycle
advanced2:00remaining
Spacer composable with fillMaxSize modifier
What is the effect of using Spacer with Modifier.fillMaxSize() inside a Box?
Box(modifier = Modifier.size(100.dp)) {
Spacer(modifier = Modifier.fillMaxSize())
Text("Hello")
}Android Kotlin
Box(modifier = Modifier.size(100.dp)) { Spacer(modifier = Modifier.fillMaxSize()) Text("Hello") }
Attempts:
2 left
💡 Hint
fillMaxSize makes Spacer fill all available space inside its parent.
✗ Incorrect
Spacer fills the 100.dp Box fully, but since Text is drawn after Spacer, it appears on top.
📝 Syntax
advanced2:00remaining
Correct syntax for Spacer with padding and size
Which option correctly creates a Spacer with 8.dp padding and 40.dp width and height?
Attempts:
2 left
💡 Hint
Use dp units and chain modifiers correctly.
✗ Incorrect
Modifier.padding and Modifier.size require dp units and can be chained; order matters for padding outside size.
🔧 Debug
expert2:00remaining
Why does this Spacer not add space in a Row?
Given this code, why is there no visible space between the Text composables?
Row {
Text("Left")
Spacer(modifier = Modifier.height(16.dp))
Text("Right")
}Android Kotlin
Row {
Text("Left")
Spacer(modifier = Modifier.height(16.dp))
Text("Right")
}Attempts:
2 left
💡 Hint
Consider the layout direction and which dimension the Spacer affects.
✗ Incorrect
In a Row, horizontal space is controlled by width; height modifier on Spacer does not add horizontal space.