How to center a button in jetpack Compose?

Viewed 10053

I am creating a simple counter app using jetpack compose and want , button to be placed in center of the layout , i tried using Modifier.gravity(Alignment.Center) , but its not providing any result , what should be the way to implement this ?

1 Answers

You can use something like:

Column(
        modifier = Modifier.fillMaxWidth().fillMaxHeight(),
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally
) {
    Button(onClick = {})
    { Text("BUTTON") }
}

enter image description here

Related