Now that Compose and Compose UI are in their first beta, teams may start to think about beginning to use these technologies in their apps. If your team is among them, you should consider taking this opportunity to also clean up other shaky practices in your current UI implementation.
For example, you might want to stop thinking of screen sizes.
Some Android developers are fixated on finding screen dimensions, then trying to use them. For example, in Compose UI, you can find the screen height using LocalConfiguration.current.screenHeightDp.
However, this is not really a good idea… because your app may not be using the full screen.
Most Android devices nowadays support split-screen mode. Many users will not be using that mode, but some will. In split-screen mode, your app’s window is not going to take up the full screen, but rather only part of it.
Chrome OS devices, and specialty “desktop-style environments” like Samsung DeX, use Android’s free-form multiwindow support. In this case, your app’s window also is not going to take up the full screen, but rather only part of it. Many users will not be using this sort of device or environment, but some will.
With “foldables”, the screen size can change, and users may be more prone to use split-screen mode. We might soon get “rollable” phones
. Who knows what other form factors will follow those? After all, who would have predicted the LG Wing
(personally, I half expect the next segment to be “crumple-ables”)
You might look at all of those and conclude that none of them are very popular. That may well be true. However, combined, the number of users using one of those environments might be interesting.
More importantly, manufacturers keep trying
, presumably with some encouragement and support from Google. Eventually, something is going to become a hit, either on its own merits or because Apple decides that it is cool
In other words, the era of “one screen = one app” most likely is coming to a close.
So, rather than think in terms of “how big is the screen?”, think instead in terms of “how much space do I have?”. We saw this a few weeks ago in the “How Big Are We?” post in the “One Off the Slack” series
. You can use things like BoxWithConstraints or onSizeChanged() to be able to adapt your UI to match the available space, and let the system worry how much space that is.
Adopting Compose UI will require a significant overhaul of your UI code, as you adopt Compose UI progressively through your app. While you are making those changes, think through what other assumptions your code is making, and see if you can avoid making those assumptions, to better future-proof your UI. After all, you never know when someday your app needs to run on a phone that the user can just crumple up and shove in their pocket.