Ranjithkumar
Ranjithkumar

Reputation: 18416

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

Upvotes: 15

Views: 11524

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364780

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

Upvotes: 45

Related Questions