14

I follow the official document to learn about Rows.

It's working fine. It arrange views horizontally and application runs without any issues.

Problem:

I want to set horizontalArrangement in Row. It didn't arrange it.

My code:

@Composable
fun SimpleRowArrangement(){
    Row(horizontalArrangement  =  Arrangement.SpaceEvenly,
            verticalAlignment = Alignment.Bottom) {
        Text(text = "Row Text 1")
        Text(text = "Row Text 2")
        Text(text = "Row Text 3")
    }
}

Output: enter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Ranjithkumar
  • 16,071
  • 12
  • 120
  • 159

1 Answers1

34

You should apply also the fillMaxWidth modifier.

Row(
    modifier = Modifier.fillMaxWidth(),
    horizontalArrangement = Arrangement.SpaceEvenly,
    verticalAlignment = Alignment.Bottom
) {
        Text(text = "Row Text 1")
        Text(text = "Row Text 2")
        Text(text = "Row Text 3")
    }

enter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • 5
    working fine. In documentation they didn't mention anything. Thanks for your answer – Ranjithkumar Aug 05 '21 at 12:09
  • And if I want one ```Text``` at the start, one ```Text``` at the end of ```Row(Modifier.fillMaxWidth)``` So, how to achieve it ? – Michael Abyzov Dec 13 '22 at 16:35
  • 1
    @MichaelAbyzov You can use `Arrangement.SpaceBetween`. Check also https://stackoverflow.com/a/64433116/2016562 – Gabriele Mariotti Dec 13 '22 at 16:37
  • `VerticalAlignment` doesn't compile. – IgorGanapolsky Jan 16 '23 at 01:33
  • 1
    @IgorGanapolsky the `verticalAlignment` attribute exists. check also the [doc](https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#Row(androidx.compose.ui.Modifier,androidx.compose.foundation.layout.Arrangement.Horizontal,androidx.compose.ui.Alignment.Vertical,kotlin.Function1)) – Gabriele Mariotti Jan 16 '23 at 07:51