EN VI

Kotlin - removes spaces around buttons?

2024-03-12 15:30:07
How to 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),
Answer

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login