Challenge - 5 Problems
Box Layout Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
Box layout stacking order
Given a Box layout with three overlapping Text composables, which Text will appear on top?
Android Kotlin
Box {
Text("First", modifier = Modifier.align(Alignment.Center))
Text("Second", modifier = Modifier.align(Alignment.Center))
Text("Third", modifier = Modifier.align(Alignment.Center))
}Attempts:
2 left
💡 Hint
Think about the order composables are declared inside the Box.
✗ Incorrect
In a Box layout, children declared later are drawn on top of earlier ones. So the last Text composable "Third" appears on top.
❓ ui_behavior
intermediate2:00remaining
Box layout alignment behavior
What will be the position of a Text composable inside a Box with modifier.align(Alignment.BottomEnd)?
Android Kotlin
Box(modifier = Modifier.size(100.dp)) { Text("Hello", modifier = Modifier.align(Alignment.BottomEnd)) }
Attempts:
2 left
💡 Hint
Alignment.BottomEnd means bottom and right edges.
✗ Incorrect
Modifier.align(Alignment.BottomEnd) places the composable at the bottom-right corner inside the Box.
❓ lifecycle
advanced2:00remaining
Box layout size with multiple children
If a Box contains two children with fixed sizes 100.dp and 150.dp, what will be the size of the Box by default?
Android Kotlin
Box {
Box(modifier = Modifier.size(100.dp)) {}
Box(modifier = Modifier.size(150.dp)) {}
}Attempts:
2 left
💡 Hint
Box size depends on the largest child by default.
✗ Incorrect
By default, Box sizes itself to fit the largest child. So it will be 150.dp by 150.dp.
📝 Syntax
advanced2:00remaining
Correct syntax for Box with padding and background
Which option correctly applies 16.dp padding and a red background color to a Box?
Attempts:
2 left
💡 Hint
Order of modifiers affects layout and appearance.
✗ Incorrect
Padding should come before background to apply padding inside the background. Also, 16.dp is required, and Color.Red must be capitalized.
🧠 Conceptual
expert2:00remaining
Box layout vs Column layout behavior
Which statement best describes the difference between Box and Column layouts in Jetpack Compose?
Attempts:
2 left
💡 Hint
Think about how children are placed visually in each layout.
✗ Incorrect
Box overlays children, stacking them; Column places children vertically in order.