https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
s

Shoaib khalid

10/04/2023, 6:00 PM
How to get screen width and height for Ios and Android in common module in compose Multiplatform? see more detail here: https://github.com/JetBrains/compose-multiplatform/discussions/3225
a

Alejandro Rios

10/04/2023, 6:28 PM
a possible solution would be using the
OnGloballyPositionedModifier
modifier, there was this option but not sure if already works
a

Alexander Zhirkevich

10/04/2023, 7:48 PM
With the help of expect/actual you can use
LocalConfiguration.current.screenWidthDp
on Android and
LocalWindowInfo.current.containerSize
on non-Android (starting from 1.5.10-beta01).
👍🏻 1
a

Alex Vanyo

10/06/2023, 6:16 PM
I’d recommend against
LocalConfiguration.current.screenWidthDp
on Android - due to insets it can be smaller than the actual window size, and due to density rounding it can be off by at least a pixel from the true actual window size.
WindowMetricsCalculator.computeCurrentWindowMetrics
is the way to go.
👍 1
10 Views