is windowsizeclass width the good election when yo...
# compose
p
is windowsizeclass width the good election when you wanna use a different design in landscape or portrait tablets/phones/chromecast? can a device be windowsizeclass height and width expanded at the same time? In the docs google focus a lot in windowsizeclass when designing for different screen sizes, and I need my screen to display a different screen structure when it's in landscape, because the height is not enought to paint some panes, but I'm not sure what will happen if I use expanded windowsizeclass width to determine if to display a "landscape" structure if the device is for example a very high res device with also expanded window size height. According to the docs, anything above 840dp width is expanded width and anything above 900dp height is expanded height.
a
If you need a minimum amount of height available, you could also add a requirement to meet at least a specific height size class in addition to the width size class - for example, you could show a specific layout if at an expanded width size class (840dp or wider) and if at a medium height size class (480dp or taller)
can a device be windowsizeclass height and width expanded at the same time?
Yes - the height and width size classes are independent: a window could be in an expanded width and a compact height, or it could be at a compact width but an expanded height
We generally talk about width size classes more since so many things have vertical scrolling, but the height size classes are there to use too
p
then, it's prefeerable to use screen orientation instead of windowsizeclass if you simply need different screens if it's landscape or portrait instead of checking minimum height? I don't know minimum height, components are lists and items with variable height.
a
I would avoid using landscape and portrait directly if you can and favor breakpoints. Windows that are close to square can either be just barely portrait or just barely landscape, and it can be confusing if crossing that threshold dramatically changes the layout of the app. A specific example that we’ve seen be confusing to users is logic to show two panes (like a list-detail layout) in landscape only, and not in portrait. Let’s say you have a window that is just barely landscape, so you’re showing two panes. Then, you resize the window to make it taller. That will eventually result in a window that is just barely portrait, so therefore you will only show one pane. That feels weird because giving the app more room to display content resulted in less content being displayed
p
But if I do this:
Copy code
val windowWidthSizeClass = currentWindowAdaptiveInfo().windowSizeClass.windowWidthSizeClass
if (windowWidthSizeClass == WindowWidthSizeClass.EXPANDED) {
I got a huge issue, and it's that in devices with small screen, for example, small phones, width is never expanded, so I get the "portrait" style interface always, even when the device is in landscape