Search code examples
androidandroid-layoutandroid-jetpackandroid-jetpack-compose

How to stack Text vertically with rotation using Jetpack Compose?


Trying to align text elements as shown in the image below:

enter image description here

How to do it in Jetpack Compose?

Normally I would use a Linear Layout with vertical orientation and TextViews with a rotation of 90. Wondering how to achieve this in compose.


Solution

  • compose_verion: 1.0.0-beta02

    To rotate an element you can use Modifier.rotate() modifier

    Column {
         Text(text = "text", modifier = Modifier.rotate(-90f))
         Text(text = "text", modifier = Modifier.rotate(-90f))
         Text(text = "text", modifier = Modifier.rotate(-90f))
    }