Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center a button in jetpack Compose? [closed]

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 ?

like image 772
Ansh Avatar asked Sep 02 '20 14:09

Ansh


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

like image 137
Gabriele Mariotti Avatar answered Sep 25 '22 11:09

Gabriele Mariotti