How to center Column content in Jetpack Compose?
Hi! I've just started learning Jetpack Compose and encountered what seems like a simple task: I need to place several elements inside a Column in the center of the screen, but I can't get it to work.
Here's my code:
\n\n@Composable\nfun MyScreen() {\n Column(\n modifier = Modifier.fillMaxSize()\n ) {\n Text("Hello, world!")\n Button(onClick = { }) {\n Text("Click me")\n }\n Text("Bottom text")\n }\n}\n\nEverything is stuck to the top-left corner. I've tried different modifiers: Modifier.align(Alignment.CenterHorizontally) on each element — this only works horizontally, but vertically they're still at the top. I tried adding Modifier.weight(1f) — it made things worse
No answers yet.
Log in to leave an answer