https://kotlinlang.org logo
#compose
Title
# compose
k

Kazemihabib1996

05/27/2020, 7:19 PM
Applying
relativePaddingFrom
after
preferredSize
centers the children is that a bug? it works correctly when applied before
preferredSize
Copy code
Box(
            gravity = ContentGravity.BottomStart,
            modifier = Modifier
                .drawBackground(Color.Green)
                .preferredSize(200.dp)
                .relativePaddingFrom(FirstBaseline, after = 30.dp)

        ) {
            Text(
                text = "Example of after relativePaddingFrom"
            )
        }
z

Zach Klippenstein (he/him) [MOD]

05/27/2020, 7:26 PM
Modifier order is sometimes significant, especially with layout ones. Eg I think if you put the background color modifier after the padding, the color will be padded too (or maybe the other way around?)
k

Kazemihabib1996

05/27/2020, 7:46 PM
@Zach Klippenstein (he/him) [MOD] Yes, I've been playing around with order of modifiers these days and I made a formula for my self.😅 If I apply padding before background it knows nothing about the background color that we want to apply afterward so it's wont be colored. if we apply the background color before padding now it knows the color and will inherit the color. but this one is different I don't understand it. applying
relativePaddingFrom
after
preferredSize
centers the Text inside box instead of adding a padding.
🤔 2
m

Mihai Popa

05/28/2020, 2:14 PM
Definitely a weird behavior, could you please file a bug? 🙂
k

Kazemihabib1996

05/28/2020, 3:40 PM
3 Views