image.png
# compose
t
image.png
ha, got it 🙂
Copy code
@Composable
fun DateSeparator(date: Date) {
    Stack() {
        Align(Alignment.Center) {
            Divider(color = Color.Gray, height = 2.dp)
        }
        Align(Alignment.Center) {
            Surface(color=Color.White) {
                Text("Yesterday", modifier = LayoutPadding(10.dp))
            }
        }
    }
}
z
Which version of Compose are you using? That code works for me:
Also
Center
is an abbreviation for
Align(Center)
m
I think you should be using modifiers instead of positioning containers like that. Less nesting that way.
LayoutGravity.Center
works. I also think stack/row/column are missing a
gravity
param. It makes sense to me to set all children's alignment then let each child set their own if they want.
☝️ 1
a
Yeah the default child gravity param is coming back
🎉 6
t
Nice, so far i think alignment is the most confusing aspect of Compose.
Super cool to see the work you guys are doing on Compose. I think it's going to have a massive impact on Android development
❤️ 1
@mon can you clarify what you mean?
👍 1
m
You could do something like
Copy code
Stack {
  Divider(modifier = LayoutGravity.Center, ...)
  Surface(modifier = LayoutGravity.Center, ...) {
    Text(...)
  }
}
I find this way cleaner that having to nest each child in a
Center
or
Align