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

Daniele Segato

01/27/2023, 8:21 AM
Can you recommend an API / approach to have a widget expand outside of its boundaries? I'll try to clarify my question with an example: picture a Button that when clicked is expanded into N other buttons that radiate out of it. Ideally the widget just take the space for the original button and doesn't change in size for what concern the outside container. I know that I can use
Modifier.offset
but I was wondering if there was a way to define the expanded state as a regular composable instead of having each satellite-button on top of each other and offsetting them outwards with
Modifier.offset
. I'm not trying to realize this widget, I'm just looking into learning if there is some way of achieving this "escape boundaries" behavior and if yes how. Thank you
a

Albert Chang

01/27/2023, 8:24 AM
Modifier.wrapContentSize(unbounded = true)
d

Daniele Segato

01/27/2023, 8:42 AM
unbounded let me go past the
maxSize
provided from outside but it still change the size of the widget from outside
a

Albert Chang

01/27/2023, 8:44 AM
Of course you need some kind of placeholder to take the space the original content took, otherwise how would the layout knows what the size was?
d

Daniele Segato

01/27/2023, 8:45 AM
I want the widget to be if size 48x48dp but draw in a 128x128dp area (example numbers)
a

Albert Chang

01/27/2023, 8:46 AM
Then you can just use
Copy code
Modifier
    .size(48.dp)
    .wrapContentSize(unbounded = true)
    .size(128.dp)
d

Daniele Segato

01/27/2023, 8:46 AM
say expanded state is 4x the actual widget size. from outside the widget doesn't change in size when it expand -kind-of-thing
oh right, I didn't think of that, in a box I can use
Copy code
Modifier.matchParentSize()
      .wrapContentSize(unbounded = true)
thanks
6 Views