Challenge - 5 Problems
Compose UI Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate1:30remaining
What happens when you use Modifier.padding in Compose?
In Jetpack Compose, what is the visual effect of applying Modifier.padding(16.dp) to a Text composable?
Android Kotlin
Text("Hello", modifier = Modifier.padding(16.dp))
Attempts:
2 left
💡 Hint
Think about what padding means in everyday life, like adding space inside a box.
✗ Incorrect
Modifier.padding adds space inside the composable's boundary, pushing the content inward and creating empty space around it.
❓ lifecycle
intermediate1:30remaining
When does Compose recomposition happen?
In Jetpack Compose, which of the following triggers recomposition of a composable function?
Android Kotlin
var count by remember { mutableStateOf(0) }
Button(onClick = { count++ }) {
Text("Clicked $count times")
}Attempts:
2 left
💡 Hint
Think about what causes the UI to update when data changes.
✗ Incorrect
Compose automatically recomposes when a state variable used inside a composable changes, updating the UI accordingly.
advanced
2:00remaining
How does Compose Navigation handle back stack?
In Jetpack Compose Navigation, what happens when you call navController.navigate("screenB") and then press the back button?
Android Kotlin
navController.navigate("screenB")Attempts:
2 left
💡 Hint
Think about how back stacks work in real life, like pages in a book.
✗ Incorrect
Navigation adds screens to a stack. Pressing back removes the top screen, returning to the previous one.
📝 Syntax
advanced2:00remaining
What is the output of this Compose code snippet?
Consider this code snippet in Jetpack Compose. What text will be displayed?
Android Kotlin
var name by remember { mutableStateOf("Alice") }
Column {
Text("Hello, $name")
Button(onClick = { name = "Bob" }) {
Text("Change Name")
}
}Attempts:
2 left
💡 Hint
Remember how state variables update UI in Compose.
✗ Incorrect
The Text composable reads the state variable 'name'. Clicking the button updates 'name', triggering recomposition and updating the text.
🧠 Conceptual
expert2:30remaining
Why does Compose enable building rich UIs efficiently?
Which of the following best explains why Jetpack Compose allows developers to create rich and dynamic UIs more efficiently than traditional Android Views?
Attempts:
2 left
💡 Hint
Think about how describing UI as a function of data helps keep UI in sync.
✗ Incorrect
Compose's declarative approach means developers write UI as functions that react to state changes, reducing errors and boilerplate code.