Morning composers, I got a `Box` in a `Box` and I ...
# compose
i
Morning composers, I got a
Box
in a
Box
and I want to offset the inner box by
x
dps from the left, I tried left padding and offset though nothing seems to work
Copy code
Box(Modifier.background(Color.Red).width(128.dp).height(128.dp)) {
        Box(Modifier.background(Color.Green).width(32.dp).height(128.dp)) {

        }
    }
I want the inner box to have some space on the left hand size that I can specify hope that makes sense
a
How about Modify.align it to the right?
padding for the inner box should also work though. might just be a problem with the ordering
i
Cheers I wanted some exact positioning like 32.dp from the left or something though seems not to work like that, maybe margin is something I need though don't seem to find a Modifier for that
a
there’s no margin in compose. But what you meant by margin is adding padding aT the top-most order
let me make a poc really quickly
🙏 1
i
cheers!
This is what I tried
Copy code
Box(Modifier.background(Color.Red).width(128.dp).height(128.dp)) {
        Box(Modifier.background(Color.Green).width(32.dp).height(128.dp).offset(32.dp)) {

        }
    }
and I get this in Preview
I tried padding start and padding left to get the green bar offset where I want it (say 32.dp in) though still did not move the green bar
a
you want this right?
ah, sorry, should just be padding(start = 16.dp)
i
kinda just the green bar to not have padding at top or bottom
aha! I think it might be Modifier ordering?
a
yep
👍 1
i
I put mine last and not first in the modifier list
a
modifier order matters
i
nice one!
a
Compose Preview is ridiculously slow…
i
yeh thanks! 🙂 it works
yeh and sometimes bugs out I think
a
i
lovely cheers works