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

frankelot

12/07/2020, 6:13 PM
Quick question, I want to have a layout where children views can place themselves wherever they want (x y relative to the parent layout)… not sure how to acomplish this in #Compose 🤔 Tried creating a custom layout and using:
Copy code
placeable.placeRelative(x = 0, y = 0)
but I don’t have a way of asking the view where it wants to be placed
I understand that in 99% of cases the
layout
should be the one in charge of placing its children views… but I want to create a set of draggable views that the user can move around freely
r

Rafs

12/07/2020, 6:20 PM
You can use a Box as the parent composable and give it a modifier of
fillMaxSize()
After that you can place your children using
Modifier.Offset(x, y)
f

frankelot

12/07/2020, 6:20 PM
👀 that looks promising, thanks @Rafs! will give it a try
b

bruno.aybar

12/08/2020, 12:07 AM
There's also BiasAlignment , which allows you to align content given a bias
Copy code
modifier.align(BiasAlignment(horizontalBias, verticalBias))
the bias value goes from -1 (start / top) to 1 (end / bottom)