Specifying Width in Jetpack Compose
最終更新日:2024-08-03
To set the width of a Composable to a specific size, pass Modifier.width()
to the modifier parameter. The unit is dp
.
@Composable
fun Greeting(name: String) {
Row {
Text(text = "ねぇ", modifier = Modifier.width(60.dp))
Text(text = "$name!")
}
}
"ねぇ" text width is set to 60dp instead of content size.