Is there any way to get the `size` of the screen a...
# compose
a
Is there any way to get the
size
of the screen as a value? I thought it would be available in
LocalDensity.current
but it isn't.
Okay, found it. For anyone wondering:
Copy code
LocalConfiguration.current.screenHeightDp
👍 1
c
From what I've read in this slack before... depending on what you're doing you may want to get the height of the parent container and not the screen height. For example if you're in split screen mode... you probably want to get the value of the parent container. I suspect a lot of times parentContainerHeight == screenHeight, but split screen is a good example of when that's not true.
a
That is a good point. Are there any references to that height?
a
Adib you can probably use Modifier.onGloballyPositioned.
a
That is very different from my scenario. I don't want the height of the current composable.
z
BoxWithConstraints
is the usual way to do what Colton is talking about. The
onGloballyPositioned
modifier is the wrong thing for that in most cases, can cause a frame delay.
a
Both solutions are not what Colton was talking about. Both these solutions give the size of the
Latout
not the window. You need to get the window information anywhere you want.
z
Colton was talking about getting the size of the container, instead of the window.
BoxWithConstraints
is usually the simplest way to do that. It sounds like that’s not what you need but wanted to clarify.
👍 1