Search code examples
kotlinbuttonalignment

Kotlin - removes spaces around buttons


I'm playing around with the code. Below is my code, and it seems like there's some default spacing causing the buttons to be separated. I would like to remove the spaces, so button "A" sits right on top of button "B". Could someone help me with this?

Thanks.

fun MyUserInterface(){
Column(modifier = Modifier
    .fillMaxSize()
    .padding(32.dp)
    .border(BorderStroke(2.dp, Color.Red))){
        Button(onClick = { /*TODO*/ }) {
            Text(text = "A")
        }
        Button(onClick = { /*TODO*/ }) {
            Text(text = "B")
        }
        Button(onClick = { /*TODO*/ }) {
            Text(text = "C")
        }
        Button(onClick = { /*TODO*/ }) {
            Text(text = "D")
        }
        Button(onClick = { /*TODO*/ }) {
            Text(text = "E")
        }
}

}


Solution

  • To modify spacing for the whole column use Arrangement.spacedBy:

    Column(
        verticalArrangement = Arrangement.spacedBy((-8).dp),