https://kotlinlang.org logo
#compose
Title
# compose
m

Mehdi Haghgoo

02/14/2021, 12:28 AM
How can I align one item in the column to the top and other items to the center?
Copy code
var showMessage by remember { mutableStateOf(false) }

        Column (verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.background(Color.Red).size(200.dp)){

            if (showMessage) {
                BasicText(
                    "You Pressed The Button",
                    style = TextStyle.Default.copy(fontStyle = FontStyle.Italic),
                )
            }


            Button(
                onClick = { showMessage = !showMessage },
            ) {
                BasicText("Show")
            }



        }

    }
Currently, the problem is both Text and Button are fighting to be in the center of Column.
d

Denis

02/14/2021, 8:08 AM
Try to make a nested layout (Column or Row maybe)
👍 1
k

Kshitij Patil

02/14/2021, 8:39 AM
You need to use
Box
for that.
👍 1
2 Views