Specifying Height in Jetpack Compose
Last updated:2024-06-16
To set the height of a Composable to a specified size, pass Modifier.height() to the modifier parameter. The unit is dp.
@Composable
fun Greeting2(name: String) {
Column {
Text(text = "こんにちは",
modifier = Modifier.height(40.dp))
Text(text = "$name!")
}
}
"こんにちは" text height is set to 40dp instead of content size.