# Don't Lock the Screen Orientation! Handling Orientation in Compose

DevFeed: [Don't Lock the Screen Orientation! Handling Orientation in Compose](<https://devfeed.tech/articles/don-t-lock-the-screen-orientation-handling-orientation-in-compose-38486.md>)

Original publisher: [Read original article](<https://eevis.codes/blog/2024-07-18/dont-lock-the-screen-orientation-handling-orientation-in-compose/>)

Author: Eevis Panula

Published: 2024-07-22T04:29:54.355000Z

Content type: tutorial

Language: en

Sources: [Eevis Blog](<https://devfeed.tech/sources/eevis-blog.md>)

Topics: [Compose](<https://devfeed.tech/topics/compose.md>), [Android](<https://devfeed.tech/topics/android.md>), [android-apps](<https://devfeed.tech/topics/android-apps.md>), [ui](<https://devfeed.tech/topics/ui.md>), [configuration](<https://devfeed.tech/topics/configuration.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [compose](<https://devfeed.tech/tags/compose.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [handling](<https://devfeed.tech/tags/handling.md>), [layout](<https://devfeed.tech/tags/layout.md>), [orientation](<https://devfeed.tech/tags/orientation.md>), [screen](<https://devfeed.tech/tags/screen.md>)

## AI overview

This tutorial explains why Android apps should generally support both portrait and landscape orientations, especially for accessibility and users who cannot rotate their devices. It focuses on Compose layout considerations, testing responsive layouts, and handling configuration changes caused by screen rotation.

## Source excerpt

Yes, your app should work in both portrait and landscape modes - unless locked orientation is essential for functionality, like in a piano app. However, for most apps, locked orientation is not an option. Oh, and yes, the functionality should be similar in both modes, not hiding anything when the orientation changes. In this blog post, I'll cover the topic of locked orientation. It's mainly concentrated on Compose things, but there might be something useful for Views, too. I've also included some good articles in the Read More section of the blog post, explaining, e.g., more about orientation locking themes on Views. This blogpost was updated on 22nd of July to add example of using WindowWidthSizeClass. Why Locking Orientation is a Problem? When discussing locked orientation and its problems, we usually refer to locking the orientation to portrait mode. Unfortunately, this is a typical case among Android apps. Why is this a problem, then? Some people prefer to use their phones in landscape mode because it gives them more screen width. A wider screen can make it easier for people who use, e.g., larger font sizes of screen magnification. And some people might have their phones mounted on, e.g., a wheelchair in landscape mode, and can't rotate the phone at all. In these cases, if the app's orientation is locked in portrait mode, using the app might be more complicated or even impossible. That is not what any developer behind the apps wants, right? So, let's talk about how to support different orientations on your app. It's Straightforward From a purely UI point of view, supporting landscape mode is pretty straightforward. You just don't do anything - like prevent the screen rotation. This way, the landscape mode is available. Of course, you need to test that the layouts actually look okay in landscape orientation. With Compose, the layout mostly works if you don't use exact widths for different elements and don't have sticky items that take up some vertical space on th