Jetpack Compose Center Text Vertically

December 15, 2021

If text is child of Card or Box.

Card(modifier = Modifier.fillMaxWidth().padding(8.dp)) {
    Row {
        Image(data = uri)
        Text(
            modifier = Modifier.padding(8.dp).align(Alignment.CenterVertically),
            text = "Center this text vertically"
        )
    }
}

Else

Row(verticalAlignment = Alignment.CenterVertically) {
    Button(onClick = { }) {
        Text(text = "Click Me")
    }

    Text(
        modifier = Modifier.padding(8.dp),
        text = "Hello    
    )
}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.