Hi, If I need size changes of a Composable. I can ...
# compose
a
Hi, If I need size changes of a Composable. I can get that using
onSizeChanged
or
onGloballyPositioned
. Is there any use-case to prefer
onGloballyPositioned
over
onSizeChanged
when only size changes are in consideration?
s
I usually just use
.onPlaced
for this, you get the layout coords in the parent and the size of your layout too. The global one I suppose is there for if you care for position relative to the screen, and not relative to the parent
a
Oh, let me check that. I haven’t used that before. gratitude thank you
a
if you only need size please use a size specific modifier, it is easier to manage internally as sizes change less often compared to positions, especially global positions as all position changes of all parents affects the global position
thank you color 1
s
So basically try onSizeChanged first, if that's not enough go to onLayout, if that's not enough try onGloballyPositioned in that order is what you suggest? Is there some other API I'm missing?