Hello, is there a way how to absolutely position c...
# compose
d
Hello, is there a way how to absolutely position child composable within
Box
? I have a code like this
Copy code
@Preview("Positioning", widthDp = 300, heightDp = 300)
@Composable
fun Positioning() {
    Box(
        modifier = Modifier.size(300.dp)
            .background(Color.Blue)
    ) {
        Box(
            modifier = Modifier.size(20.dp)
                .background(Color.Red)
                .absoluteOffset(20.dp, 20.dp)
        )
    }
}
and I’d like to position inner
Box
but the result is not positioned. I know that it does not make sense probably to apply offset to
Modifier
of inner
Box
because I’d need to affect outer
Box
somehow but I did not find a way how to position just a single child. I know I can achieve it easily with Canvas drawing but I’m just thinking what if I’d want to position some other
Composable
. Thanks
r
You should apply offset before background. The order of modifiers matter
d
Ah.thx 🙏