0
0
Android Kotlinmobile~5 mins

Spacer composable in Android Kotlin - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AFull screen size
B10dp by 10dp
CZero size (no visible space)
DDepends on parent layout
Which modifier makes a Spacer expand to fill available space?
AModifier.clickable()
BModifier.padding()
CModifier.background()
DModifier.weight()
How do you add vertical space of 16dp between two composables?
ASpacer(Modifier.width(16.dp))
BSpacer(Modifier.height(16.dp))
CSpacer(Modifier.size(16.dp))
DSpacer(Modifier.padding(16.dp))
In a Row, what does Spacer(Modifier.weight(1f)) do?
APushes other items apart by filling remaining horizontal space
BAdds fixed 1dp space
CMakes Spacer invisible
DAdds padding around Spacer
Can Spacer be used inside both Row and Column layouts?
AYes, it works in both
BNo, only in Row
CNo, only in Column
DNo, Spacer is deprecated
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.