0
0
Android Kotlinmobile~20 mins

Surface and shape in Android Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Surface and Shape Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2: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)))
AA red square with rounded corners and a shadow around it
BA transparent box with a shadow but no color
CA red circle with a shadow
DA red square with sharp corners and no shadow
Attempts:
2 left
💡 Hint
Look at the shape used in background and shadow modifiers.
🧠 Conceptual
intermediate
1:30remaining
What does the Surface composable provide in Jetpack Compose?
In Jetpack Compose, what is the main purpose of the Surface composable?
ATo provide a container that applies background color, elevation, and shape
BTo handle navigation between screens
CTo load images from the internet
DTo draw a clickable button with text
Attempts:
2 left
💡 Hint
Think about a container that can have shadows and rounded corners.
lifecycle
advanced
2: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?
ANothing changes because shape is not a state
BThe Surface recomposes and redraws with the new shape
CThe app crashes due to shape mismatch
DThe Surface ignores the new shape and keeps the old one
Attempts:
2 left
💡 Hint
Changing parameters that affect UI appearance triggers recomposition.
📝 Syntax
advanced
2: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.
ASurface(shape = RoundedCornerShape(50%), elevation = 12.dp) { /* content */ }
BSurface(shape = CircleShape(), elevation = 12) { /* content */ }
CSurface(shape = CircleShape, elevation = 12) { /* content */ }
DSurface(shape = CircleShape, elevation = 12.dp) { /* content */ }
Attempts:
2 left
💡 Hint
Check the correct usage of CircleShape and elevation parameter type.
🔧 Debug
expert
2: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)) }
ABecause elevation only works with MaterialTheme colors
BBecause the Box inside covers the Surface, hiding the shadow
CBecause the Surface color is transparent, the shadow is not drawn
DBecause RoundedCornerShape does not support shadows
Attempts:
2 left
💡 Hint
Surface elevation shadow visibility depends on the color parameter.