Search code examples
androidandroid-jetpack-composeandroid-jetpack-compose-layout

Horizontal Arrangement not working in Jetpack Compose Row


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


Solution

  • 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