Search code examples
androidandroid-layoutandroid-jetpack-compose

Jetpack compose: position elements inside a Box


I have a Box in my app with a bunch of children:

Box(modifier = Modifier.fillMaxSize()) {
    Text("a")
    Text("b")
}

I want the text to appear aligned to the top at 20% distance from the start. How do I achieve that?


Solution

  • Use the offset/absoluteOffset modifiers along with BoxWithConstraints.