0
0
Android Kotlinmobile~20 mins

Card composable in Android Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Card Composable Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What is the visual output of this Card composable code?
Consider this Kotlin Compose code snippet for a Card. What will the user see on the screen?
Android Kotlin
Card(
  modifier = Modifier.size(100.dp),
  elevation = 8.dp
) {
  Text("Hello Card", modifier = Modifier.padding(16.dp))
}
AA plain text 'Hello Card' without any card background or shadow
BA card with no shadow and no padding around the text
CA card with a shadow and the text 'Hello Card' inside with padding
DAn empty card with no visible content
Attempts:
2 left
💡 Hint
Remember that Card adds elevation by default and the Text has padding inside the card.
lifecycle
intermediate
2:00remaining
What happens when you update the state inside a Card composable?
If you have a Card composable displaying a counter and you update the counter state, what happens to the Card UI?
Android Kotlin
var count by remember { mutableStateOf(0) }
Card {
  Text("Count: $count")
}
// On button click: count++
AThe Card recomposes and updates the displayed count immediately
BThe Card does not update until the whole screen is refreshed
CThe Card crashes because state cannot be used inside Card
DThe Card UI freezes and does not show the updated count
Attempts:
2 left
💡 Hint
Compose automatically updates UI when state changes inside composables.
📝 Syntax
advanced
2:00remaining
Which option correctly sets a rounded corner shape on a Card?
You want to create a Card with rounded corners of 12.dp radius. Which code snippet does this correctly?
ACard(shape = RoundedCornerShape(12.dp)) { Text("Rounded Card") }
BCard(cornerRadius = 12.dp) { Text("Rounded Card") }
CCard(shape = CornerRadius(12.dp)) { Text("Rounded Card") }
DCard(borderRadius = 12.dp) { Text("Rounded Card") }
Attempts:
2 left
💡 Hint
Look for the correct parameter name and type for shape in Card composable.
navigation
advanced
2:00remaining
How to navigate to a new screen when a Card is clicked?
You want to navigate to a DetailScreen when the user taps on a Card. Which approach correctly handles this?
Android Kotlin
Card(modifier = Modifier.clickable { /* navigate */ }) {
  Text("Go to Details")
}
ASet a click listener on Text inside the Card to navigate
BWrap Card inside a Button composable and use onClick to navigate
CUse Card's onClick parameter to call navController.navigate("detail")
DUse Modifier.clickable with a lambda calling navController.navigate("detail") inside the Card
Attempts:
2 left
💡 Hint
Card itself does not have an onClick parameter; use Modifier.clickable instead.
🔧 Debug
expert
2:00remaining
Why does this Card not show elevation shadow?
This Card composable code does not show any shadow even though elevation is set. What is the cause?
Android Kotlin
Card(
  modifier = Modifier.size(100.dp),
  elevation = 8.dp,
  backgroundColor = Color.Transparent
) {
  Text("No Shadow")
}
AElevation must be set using shadow() modifier, not elevation parameter
BSetting backgroundColor to Transparent removes the shadow effect
CCard requires a border to show elevation shadow
DText inside Card must have padding to show shadow
Attempts:
2 left
💡 Hint
Think about how transparent backgrounds affect shadows in Compose.