Hi, how can I get screen size as Dp/float for Andr...
# compose-ios
s
Hi, how can I get screen size as Dp/float for Android & IOS targets with Compose Multiplatform? Need some alternative to
LocalConfiguration
because I need size synchronously and some variants like
BoxWithConstraints
is not applicable.
i
It's platform specific, so you have to use expect actual. For ios/desktop I recently added this way to do that:
LocalWindowInfo.current.containerSize
It's experimental now and will be available in the next release
👍 1
r
You can use also
.onSizeChanged()
for the parent container.
i
In most cases yes: use modifier callbacks like
onGloballyPositioned
on root element and remember size for usage in your calculations. In this case it isn't really "synchronous" way + there is an issue with not full screen compose canvas (currently there are a few more issues with not full screen compose, but it's another story)
👍 1