Challenge - 5 Problems
Surface and Shape Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What is the visual result of this Kotlin Compose code?
Consider this Compose UI code that draws a shape with a shadow. What will the user see on the screen?
Android Kotlin
Box(modifier = Modifier .size(100.dp) .shadow(8.dp, shape = RoundedCornerShape(16.dp)) .background(Color.Red, shape = RoundedCornerShape(16.dp)))
Attempts:
2 left
💡 Hint
Look at the shape used in background and shadow modifiers.
✗ Incorrect
The Box has a red background with rounded corners of 16.dp and a shadow of 8.dp with the same rounded shape, so the shadow follows the rounded corners.
🧠 Conceptual
intermediate1:30remaining
What does the Surface composable provide in Jetpack Compose?
In Jetpack Compose, what is the main purpose of the Surface composable?
Attempts:
2 left
💡 Hint
Think about a container that can have shadows and rounded corners.
✗ Incorrect
Surface is a container that applies background color, elevation (shadow), and shape to its content, helping to create material design surfaces.
❓ lifecycle
advanced2:00remaining
How does changing the shape parameter of a Surface affect recomposition?
If you change the shape parameter of a Surface composable dynamically, what happens in the Compose UI lifecycle?
Attempts:
2 left
💡 Hint
Changing parameters that affect UI appearance triggers recomposition.
✗ Incorrect
Changing the shape parameter causes Compose to recompose the Surface and redraw it with the new shape, updating the UI accordingly.
📝 Syntax
advanced2:00remaining
Which code snippet correctly applies a circular shape with elevation to a Surface?
Select the Kotlin Compose code that creates a Surface with a circular shape and 12.dp elevation.
Attempts:
2 left
💡 Hint
Check the correct usage of CircleShape and elevation parameter type.
✗ Incorrect
CircleShape is an object, so no parentheses needed. Elevation requires a Dp value, so 12.dp is correct. Options C and D have wrong syntax or types.
🔧 Debug
expert2:30remaining
Why does this Surface not show a shadow despite elevation set?
Given this code, why is the shadow not visible?
Surface(
modifier = Modifier.size(100.dp),
elevation = 8.dp,
shape = RoundedCornerShape(12.dp),
color = Color.Transparent
) {
Box(modifier = Modifier.fillMaxSize().background(Color.Blue))
}
Attempts:
2 left
💡 Hint
Surface elevation shadow visibility depends on the color parameter.
✗ Incorrect
Because the Surface color is transparent, the shadow is not drawn. In Jetpack Compose Material Surface, the elevation shadow is rendered based on the surface color; transparent color results in no visible shadow.