Recall & Review
beginner
What is the purpose of the
Spacer composable in Jetpack Compose?The
Spacer composable is used to create empty space between UI elements, helping to control layout spacing without adding visible content.Click to reveal answer
beginner
How do you specify the size of a
Spacer in Jetpack Compose?You specify the size of a
Spacer by applying Modifier with size functions like Modifier.height(), Modifier.width(), or Modifier.size().Click to reveal answer
intermediate
True or False:
Spacer composable can be used to push other composables apart by filling available space.True. When used with
Modifier.weight(), Spacer can expand to fill available space, pushing other composables apart.Click to reveal answer
beginner
What happens if you add a
Spacer without any size modifiers inside a Row or Column?Without size modifiers, the
Spacer has zero size and does not add any visible space between elements.Click to reveal answer
intermediate
Which modifier would you use with
Spacer to make it fill all remaining space in a Row?Use
Modifier.weight(1f) to make the Spacer fill all remaining space in a Row or Column.Click to reveal answer
What is the default size of a
Spacer composable without modifiers?✗ Incorrect
Without size modifiers, Spacer has zero size and does not create visible space.
Which modifier makes a
Spacer expand to fill available space?✗ Incorrect
Modifier.weight() lets Spacer fill remaining space in a layout.How do you add vertical space of 16dp between two composables?
✗ Incorrect
Use
Modifier.height(16.dp) to add vertical space.In a
Row, what does Spacer(Modifier.weight(1f)) do?✗ Incorrect
It expands Spacer to fill remaining horizontal space, pushing other items apart.
Can
Spacer be used inside both Row and Column layouts?✗ Incorrect
Spacer works in any layout to add space.Explain how you would use a Spacer composable to separate two buttons horizontally with flexible space.
Think about how to make Spacer fill space between buttons.
You got /4 concepts.
Describe the difference between using Spacer with fixed size modifiers and using it with weight modifier.
Consider fixed dp size versus filling available space.
You got /4 concepts.