Jetpack Compose: Getting Started

Aug 1 2023 · Kotlin 1.8.10, Android 13, Android Studio Flamingo

Part 2: Layout Your App

08. Add Spacers

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 07. Columns & Rows Next episode: 09. Organize Your Code

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You have been able to use the Column and Row Composables to arrange Composables vertically and horizontally respectively.


Let us add some space between our Image and Text Composables in the FoodCategoryItem component.

      modifier = Modifier.size(75.dp),
      horizontalAlignment = Alignment.CenterHorizontally,
  ) {

        modifier = Modifier.size(75.dp),
        painter = painterResource(id = icon),
        contentDescription = null

    // Add a 5.dp spacer between the image and the text
    Spacer(modifier = Modifier.size(5.dp))

    // remove the top padding from the text
        modifier = Modifier,
        text = category,
        textAlign = TextAlign.Center,
        fontWeight = FontWeight.Bold,
        style = MaterialTheme.typography.bodyMedium



The weight Modifier function is used to specify how much space an item should take up within a Column or Row Composable.


Row(modifier = Modifier
      verticalAlignment = Alignment.Top) {

    Text(text = "Hello World", modifier = Modifier.weight(2f))

    Spacer(modifier = Modifier.weight(1f))

    Text(text = "Hello Columns", modifier = Modifier

    Text(text = "Hello Columns", modifier = Modifier


In this session, you learned how to use the Spacer Composable to add space between Composables. You also learned how to use the weight Modifier function to specify how much space an item should take up within a Column or Row Composable.