Large screens stop honoring orientation and resizability restrictions the moment you target API 37. Here is what breaks, in the order users will notice it, and how to fix each piece without a rewrite.
For about a decade, android:screenOrientation="portrait" was the cheapest way to avoid designing a second layout. One manifest attribute bought you a predictable canvas, a camera that only had to think in one direction, and a QA matrix with a single row.
That bargain ends when you raise targetSdk to 37. On any display whose smallest width is 600dp or more, the platform stops listening to your orientation and resizability requests, and Android 17 also removes the temporary opt-out that Android 16 offered. Your portrait-only app will be dropped into a resizable window of arbitrary shape, and the window will keep changing shape while someone uses it.
This post walks through the change, the failures I would expect to see first, and a fix order that gets the visible damage out of the way early. It closes with a bonus section on desktop-mode behavior, which is where large-screen bugs get exotic.
What the platform actually stopped honoring
The scope is narrower than the headline suggests, so it is worth being precise.
When your app targets API 37 and runs on a display with a smallest width of 600dp or more, in full-screen or multi-window, these are ignored:
- Every fixed value of
android:screenOrientation, including the reverse, sensor and user variants. - The same values passed to
setRequestedOrientation(). -
android:resizeableActivity="false". -
android:minAspectRatioandandroid:maxAspectRatio.
Three things still behave the old way: displays below the 600dp threshold, apps flagged as games through android:appCategory, and apps a user has explicitly switched back to their requested behavior from the per-app aspect ratio settings.
Two details deserve a second read.
The opt-out is gone, but only for API 37. An app that opted out while targeting 36 keeps that behavior until it raises its target. Google Play’s target-API requirement is what turns this from “eventually” into “mandatory”. The Android team’s guidance points to August 2027 for new apps and updates, but the exact enforcement date is set by Play Console policy announcements, so confirm it there. You have time, but not the kind of time that lets you defer the design work.
The user can undo it, so you must survive both. Because a user can opt an app back into its requested behavior, you cannot delete your locked-mode assumptions and call it done. The adaptive path has to be correct, and the legacy path must not crash or corrupt data when someone flips the setting. The 600dp boundary is also described slightly differently across the official pages (some say “greater than”, some “at least”), so put a test device at exactly 600dp.
Before and after, in one picture
The left panel is what your users have today: a phone layout floating in the middle of a wide display, boring and harmless. The middle panel is what Android 17 does to an unprepared app. Nothing crashes. The layout just stretches, the primary action drifts out of reach, and the next resize wipes whatever the user typed. The right panel is the destination.
These are schematics rather than device captures. For your own write-up or PR, capture the real thing from a tablet emulator and a resizable emulator at the same three moments (before, after, adaptive) so reviewers can compare like with like.
Reproduce it before you fix it
Do this first, because the failures are layout-dependent and you want a red test, not a hunch.
- Raise
compileSdkandtargetSdkto 37 on a branch. - Boot a tablet emulator, a foldable emulator, and a resizable or desktop-windowing configuration.
- For apps that have not reached target 36 yet, the app compatibility framework lets you flip on the
UNIVERSAL_RESIZABLE_BY_DEFAULTchange for a package so you can preview the behavior early. - Drag the window edges. Rotate. Fold and unfold. Do all of it with a half-filled form and a live camera.
Then write down what broke. In my experience it falls into a small number of buckets.
The failure modes, ranked by how fast users find them
- State loss on resize. Size, orientation and density changes still recreate an activity by default, and now they happen constantly. Scroll offsets reset, drafts vanish, dialogs close.
- Stretched content and unreachable buttons. Anything built with
fillMaxWidth()ormatch_parentbecomes a ribbon on a wide display. On a short landscape window, a bottom-anchored Save button can be pushed off-screen inside a container that does not scroll. - Camera previews that are rotated, squashed or cropped. Code that assumed a fixed relationship between sensor orientation and device orientation stops being correct.
- Cached geometry. A
screenWidthcaptured inApplication.onCreate, a singleton holdingdisplayMetrics, or a size read once inonCreategoes stale the first time the window changes. - Orientation used as a proxy for form factor.
if (orientation == LANDSCAPE) showTwoPane()stops meaning anything when a wide window can be "portrait" and a narrow one "landscape". - Insets you never met. Fixed-portrait apps rarely ran under a desktop caption bar. Once windows are freely placed, your top content may sit under chrome you never accounted for.
- Launch-mode and back-stack surprises.
singleTaskandsingleInstanceflows behave differently when the same task can move between a full window and a floating one. - The legacy path rotting. The user opt-in means the old behavior can still appear, and if nobody tests it, it will break.
The fixes below follow that order.
Fix 1: branch on the window, not on the device
A window size class describes the window your content has right now, not the hardware under it. A tablet that the user drags narrow reports Compact, and that is the correct answer, because your layout has compact space to work with.
Wrap the lookup in one function so the rest of the codebase never mentions a breakpoint number:
enum class PaneMode { Single, RailWithDetail, MultiPane }
@Composable
fun rememberPaneMode(): PaneMode {
// androidx.window 1.4+ breakpoint API. On older artifacts, switch on
// windowSizeClass.windowWidthSizeClass instead.
val sizeClass = currentWindowAdaptiveInfo().windowSizeClass
return when {
sizeClass.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_EXPANDED_LOWER_BOUND) -> PaneMode.MultiPane
sizeClass.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND) -> PaneMode.RailWithDetail
else -> PaneMode.Single
}
}
Material’s newer window-size-class releases add larger breakpoints above Expanded for very wide windows. You do not need them on day one, but a when with a sealed result, as above, makes adding them a one-file change.
Two cautions from experience:
- Drive structure from width and use height only for vertical-pressure decisions such as collapsing a header. Height classes exist, but wide-and-short windows are common on desktop and need their own handling.
- Keep one source of truth for selection state when the layout changes. If switching from
SingletoMultiPanere-creates the detail destination, you will fetch twice and lose scroll. Hoist the selected id into aViewModeland let the pane layout read it.
For the navigation shell itself, the adaptive navigation and list-detail scaffolds in the Material 3 adaptive libraries already encode these decisions. Use them unless you have a real reason not to.
Fix 2: cap width, allow scrolling, respect insets
The two cheapest, highest-value changes in the whole migration are a maximum content width and a scroll container. Here is a form written so it behaves on a 360dp phone and a 2000dp external display:
@Composable
fun ProfileForm(
state: ProfileDraft,
onChange: (ProfileDraft) -> Unit,
onSave: () -> Unit,
modifier: Modifier = Modifier,
) {
Box(
modifier = modifier
.fillMaxSize()
.safeDrawingPadding(),
contentAlignment = Alignment.TopCenter,
) {
Column(
modifier = Modifier
.testTag("profile-form")
.widthIn(max = 480.dp)
.fillMaxWidth()
.imePadding()
.verticalScroll(rememberScrollState())
.padding(horizontal = 16.dp, vertical = 24.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
OutlinedTextField(
value = state.displayName,
onValueChange = { onChange(state.copy(displayName = it)) },
label = { Text("Display name") },
modifier = Modifier.fillMaxWidth(),
)
OutlinedTextField(
value = state.bio,
onValueChange = { onChange(state.copy(bio = it)) },
label = { Text("Bio") },
minLines = 3,
modifier = Modifier.fillMaxWidth(),
)
Button(onClick = onSave, modifier = Modifier.align(Alignment.End)) {
Text("Save")
}
}
}
}
The order of modifiers matters. widthIn(max) followed by fillMaxWidth() means "fill, but never beyond 480dp". imePadding() sits before verticalScroll on purpose: the keyboard inset should shrink the scrollable viewport, not become padding inside the scrolled content. verticalScroll then guarantees that Save is reachable in a short window. safeDrawingPadding() on the outer box covers system bars, display cutouts and the caption bar when it is present.
Pin the behavior with a test so a future refactor cannot quietly remove the cap:
@get:Rule val compose = createComposeRule()
@Test
fun formDoesNotStretchOnWideWindows() {
compose.setContent {
DeviceConfigurationOverride(
DeviceConfigurationOverride.WindowSize(DpSize(1000.dp, 600.dp)),
) {
ProfileForm(ProfileDraft(), onChange = {}, onSave = {})
}
}
compose.onNodeWithTag("profile-form").assertWidthIsAtMost(480.dp)
}
Fix 3: make resizing a non-event for your state
Every configuration change used to be rare. Now it is a drag gesture. If your activity is recreated on each one, the user feels it as lost work.
One precision point: Android 17 did relax the default for some changes. Keyboard, keyboard-hidden, navigation, touchscreen, color-mode and desk-mode UI-mode changes no longer restart the activity by default and arrive in onConfigurationChanged() instead, unless you opt back in with android:recreateOnConfigChanges. Size, orientation and density are not on that list, so they are the ones you still have to plan for.
There are two complementary moves, and you usually want both.
Put state where it can survive. Different kinds of state belong in different places:
@Parcelize
data class ProfileDraft(
val displayName: String = "",
val bio: String = "",
) : Parcelable
class ProfileViewModel(private val handle: SavedStateHandle) : ViewModel() {
val draft: StateFlow<ProfileDraft> =
handle.getStateFlow(KEY_DRAFT, ProfileDraft())
fun update(next: ProfileDraft) {
handle[KEY_DRAFT] = next
}
private companion object {
const val KEY_DRAFT = "profile_draft"
}
}
A constructor that takes only a SavedStateHandle works with the default viewModel() factory. Once the class needs other dependencies, supply them through Hilt (@HiltViewModel) or a CreationExtras-based factory that calls createSavedStateHandle().
UI-only state such as scroll position or an expanded row belongs in rememberSaveable. User input that must survive process death belongs in SavedStateHandle. Long-running work such as a scan session or an upload belongs in a ViewModel scope, never in a composable.
Stop recreating when you do not need to. For a Compose-first activity you can declare that your app handles size-related configuration changes itself:
<activity
android:name=".MainActivity"
android:exported="true"
android:configChanges="screenSize|smallestScreenSize|orientation|screenLayout">
<layout
android:minWidth="320dp"
android:minHeight="400dp" />
</activity>
I deliberately left density out. Density changes when a window moves between displays with different pixel densities, and recreation is what reloads density-dependent resources. If you opt out of it anyway, you own refreshing those resources, and embedded AndroidView or fragment content is the first place stale assets show up. I also left out the keyboard-related flags, because on API 37 they no longer recreate the activity in the first place.
There is a real trap here too. Once you opt out of recreation, nothing re-resolves your resource qualifiers. A View-based screen that depended on layout-sw600dp being re-inflated after a resize will silently keep the old layout. Compose recomposes with the new window information and is fine, but a mixed codebase needs a deliberate answer for each screen. The <layout> element is also worth setting: it gives desktop windowing a sane minimum, so users cannot shrink your window into a state you never designed.
Fix 4: the camera preview
The camera sensor has a fixed orientation. Your window used to rotate in four tidy steps and always fill the screen. Now it can be any size and aspect ratio, and it can sit on a display other than the one the app started on. Code that computed a transform once, or sized the preview from screen dimensions, will produce a stretched or sideways image.
The most reliable fix is to stop doing the math yourself. CameraX’s PreviewView accounts for sensor orientation, display rotation and scaling. If you are on Camera2, CameraViewfinder does the same job. Only fall back to hand-written transforms if you must, and if you do, size from window metrics, never from the screen.
A capture-ready composable looks like this:
@Composable
fun rememberDisplayRotation(): Int {
val view = LocalView.current
val context = LocalContext.current
var rotation by remember { mutableIntStateOf(view.display?.rotation ?: Surface.ROTATION_0) }
DisposableEffect(view) {
val displays = context.getSystemService(DisplayManager::class.java)
val listener = object : DisplayManager.DisplayListener {
override fun onDisplayAdded(displayId: Int) = Unit
override fun onDisplayRemoved(displayId: Int) = Unit
override fun onDisplayChanged(displayId: Int) {
view.display?.takeIf { it.displayId == displayId }?.let { rotation = it.rotation }
}
}
displays.registerDisplayListener(listener, Handler(Looper.getMainLooper()))
onDispose { displays.unregisterDisplayListener(listener) }
}
return rotation
}
@Composable
fun ScannerPreview(
imageCapture: ImageCapture,
modifier: Modifier = Modifier,
) {
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
val previewView = remember {
PreviewView(context).apply {
scaleType = PreviewView.ScaleType.FIT_CENTER // letterbox instead of crop
}
}
// Because we no longer get a fresh activity per rotation, tell capture explicitly.
val rotation = rememberDisplayRotation()
LaunchedEffect(rotation) { imageCapture.targetRotation = rotation }
LaunchedEffect(previewView, lifecycleOwner, imageCapture) {
val provider = ProcessCameraProvider.awaitInstance(context) // camera-lifecycle 1.4+
val preview = Preview.Builder().build().also {
it.setSurfaceProvider(previewView.surfaceProvider)
}
try {
provider.bindToLifecycle(
lifecycleOwner,
CameraSelector.DEFAULT_BACK_CAMERA,
preview,
imageCapture,
)
awaitCancellation()
} finally {
// Release only what this composable bound. unbindAll() would also
// tear down use cases that other screens in the process still own.
provider.unbind(preview, imageCapture)
}
}
AndroidView(factory = { previewView }, modifier = modifier)
}
Imports worth getting right: LocalLifecycleOwner comes from androidx.lifecycle.compose, not the older androidx.compose.ui.platform location, and awaitCancellation comes from kotlinx.coroutines. I left PreviewView's implementation mode at its default. Switching to COMPATIBLE makes it use a TextureView instead of a SurfaceView, which can help with animation and overlap but costs some efficiency, so choose it only if you see compositing problems in bubbles or overlapping windows.
What this is guarding against, in plain terms:
-
The preview looks right but saved photos are sideways. That happens when the activity is no longer recreated on rotation and
ImageCapturekeeps its original target rotation. The display listener keeps it current. -
A cropped viewfinder users read as a bug.
FILL_CENTERcrops to fill,FIT_CENTERletterboxes. For document or ID capture, where the edges matter, letterboxing is almost always the right call. - Window-versus-screen confusion. If you ever compute dimensions manually, use window metrics. On a freely resized window or a secondary display, screen size and window size are different numbers.
If your camera needs are modest, delegating capture to the system camera through an intent removes this entire category of problem.
The migration checklist
The steps are ordered by return on effort. Steps one to three remove most of the visible damage, state and camera follow, and the last two cover pointer input and desktop windowing, which most apps skip until a user complains.
A rollout shape that has worked well: land the targetSdk bump behind a branch, merge the width-cap and scroll fixes first because they are low risk, then ship state and camera changes with their own tests, and only then flip the target on your release branch. If you ship an enterprise or kiosk app that genuinely needs a fixed orientation, plan for a different strategy such as a dedicated device class, because the platform will not enforce the lock on large screens anymore.
Bonus: desktop mode gotchas
Desktop windowing is where “adaptive” gets stress-tested. A few caveats before the details: Android 17’s Beta 3 release is where bubbles and interactive picture-in-picture for desktop mode were reported as fully enabled alongside platform stability, so these behaviors are young. Treat anything here as a checklist of things to verify on current builds, not as a spec.
Connected displays
Connect a phone or tablet to a monitor and your activity can end up on a display with a different density and size than the one it launched on. Cached Resources.getSystem().displayMetrics, a static "screen width", or a camera aspect ratio computed once will all be wrong.
Read from the window, every time you need geometry:
fun Activity.currentWindowBounds(): Rect =
WindowMetricsCalculator.getOrCreate()
.computeCurrentWindowMetrics(this)
.bounds
Also recheck density-dependent work after a window moves between displays. Pixel-snapped assets and hand-rolled dp conversions are the usual offenders.
Trackpad and mouse input
Fingers and cursors are different instruments. Three things trip up apps that only ever shipped for touch.
Hover is a real state. Rows, cards and buttons are expected to respond to a pointer before it clicks. Compose gives you the pieces:
@Composable
fun FileRow(
name: String,
onClickCount: (Int) -> Unit,
modifier: Modifier = Modifier,
) {
val interaction = remember { MutableInteractionSource() }
val hovered by interaction.collectIsHoveredAsState()
Row(
modifier = modifier
.testTag("file-row")
.fillMaxWidth()
.semantics(mergeDescendants = true) {
// TalkBack and switch access activate the row through this action.
onClick(label = "Open $name") { onClickCount(2); true }
}
.onKeyEvent { event ->
val activate = event.key == Key.Enter || event.key == Key.Spacebar
if (activate && event.type == KeyEventType.KeyUp) { onClickCount(2); true } else false
}
.focusable(interactionSource = interaction)
.hoverable(interaction)
.pointerHoverIcon(PointerIcon.Hand)
.background(
if (hovered) MaterialTheme.colorScheme.surfaceVariant
else Color.Transparent,
)
.clickCountGestures(onClickCount)
.padding(horizontal = 16.dp, vertical = 12.dp),
) {
Text(name)
}
}
Double and triple click are expected. combinedClickable covers single and double, but desktop users also expect a triple click to select a whole line or row. A small gesture helper counts rapid clicks using the platform's own double-tap timeout:
fun Modifier.clickCountGestures(onClickCount: (Int) -> Unit): Modifier =
pointerInput(onClickCount) {
val window = viewConfiguration.doubleTapTimeoutMillis
var count = 0
var lastUpAt = 0L
awaitEachGesture {
awaitFirstDown(requireUnconsumed = false)
val up = waitForUpOrCancellation() ?: return@awaitEachGesture
count = if (up.uptimeMillis - lastUpAt <= window) count + 1 else 1
lastUpAt = up.uptimeMillis
onClickCount(count.coerceAtMost(3))
}
}
Design the actions so they escalate rather than conflict: one click selects, two opens, three selects everything. Because the first click fires immediately, nothing has to wait for a timeout, but it also means a double click runs the single-click handler first. Keep the level-one action harmless and idempotent, and if a screen truly needs the two to be exclusive, accept a short delay and debounce on your side. The semantics block and key handler above matter for the same reason: a pointer-only gesture is invisible to TalkBack and to keyboard-only desktop users. You can exercise this with the trackpad input injection in Compose tests, which includes double-click and triple-click:
@OptIn(ExperimentalTestApi::class)
@Test
fun tripleClickReportsThree() {
var last = 0
compose.setContent { FileRow("report.pdf", onClickCount = { last = it }) }
compose.onNodeWithTag("file-row").performTrackpadInput { tripleClick() }
assertEquals(3, last)
}
Trackpad injection is a recent addition to the Compose test library, so it needs a fairly new ui-test release and will not compile on older Compose BOMs. If yours predates it, drop this test and cover the same logic by unit-testing the click-counting function with fake timestamps.
Touch slop is tuned for fingers. Touch slop is the distance a touch may wander before the system treats it as a drag instead of a tap, and its default is sized for imprecise fingertips. Applied unchanged to a cursor, it makes drags feel sticky, because the pointer has to travel a visible distance before anything happens. A trackpad tap, meanwhile, can jitter just enough to look like the start of a drag. Pick the slop by pointer type and test with real hardware rather than trusting the emulator:
private fun ViewConfiguration.slopFor(type: PointerType): Float =
// Starting heuristic, not a platform constant. Tune on real hardware.
if (type == PointerType.Mouse) touchSlop * 0.5f else touchSlop
fun Modifier.dragGesture(
onStart: (Offset) -> Unit,
onDrag: (Offset) -> Unit,
onEnd: () -> Unit,
): Modifier = pointerInput(Unit) {
awaitEachGesture {
val down = awaitFirstDown(requireUnconsumed = false)
val slop = viewConfiguration.slopFor(down.type)
var travelled = Offset.Zero
var dragging = false
while (true) {
val change = awaitPointerEvent().changes.firstOrNull { it.id == down.id } ?: break
if (!change.pressed) break
val delta = change.positionChange()
if (!dragging) {
travelled += delta
if (travelled.getDistance() >= slop) {
dragging = true
onStart(down.position)
change.consume()
}
} else {
onDrag(delta)
change.consume()
}
}
if (dragging) onEnd()
}
}
Also give right-click a purpose. Desktop users reach for a context menu by reflex, and an app with no secondary-click behavior feels like a stretched phone app.
Free-form window resizing
A drag across a window edge produces a rapid stream of size changes, as many per second as the display refreshes. Two consequences:
- Recreation is no longer tolerable, which is one more reason to handle configuration changes yourself where you can.
- Recomposition must be cheap. Derive expensive layout decisions from the coarse pane mode, not from raw pixel widths, so a one-pixel change does not rebuild your tree. Hoist anything stateful above the layout switch.
Set <layout> minimums, as shown earlier. Without them users can shrink a window below anything you designed or tested.
App bubbles
With Android 17, bubbles became a general windowing mode rather than a feature reserved for messaging apps, so on large screens a user can float almost any app. Practically, “ready for bubbles” is close to “behaves well in multi-window”: resizable, tolerant of small sizes, and state-safe.
Google’s bubbles guide names two manifest settings. android:resizeableActivity="true" is required (on 600dp+ screens it already defaults to true for apps targeting Android 16 or later), and android:documentLaunchMode="always" is recommended so a bubbled launch does not interfere with your existing tasks:
<activity
android:name=".MainActivity"
android:resizeableActivity="true"
android:documentLaunchMode="always" />
The remaining trap is launch modes. If your app relies on singleTask or singleInstance, moving between a full window and a bubble can still deliver new intents into an existing task. Handle them by navigating, never by resetting:
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
router.handle(intent) // navigate to the target; do not clear the back stack
}
Interactive picture-in-picture
Desktop mode adds an interactive picture-in-picture layer: windows that stay on top of others and, unlike classic PiP, remain interactive. Reports on Beta 3 describe apps requesting a pinned windowing layer for this. Because the API surface locked at platform stability, read the final reference rather than copying snippets from beta-era articles.
Design-wise, assume people will click, scroll and type in that small window. A PiP surface that only renders video, with no real controls and no sensible behavior at tiny sizes, will feel broken beside the apps that treat it as a first-class window. Keep it cheap to render, and make sure focus, hover and keyboard input land where a user would expect.
🔚 Closing thoughts
The orientation lock was never a design decision. It was a way to postpone one. Android 17 collects on that postponement for any app that targets 37 and runs on a large screen, and the cost is much lower if you pay it in a planned sequence: reproduce, cap and scroll, branch on the window, protect state, fix the camera, then take on pointer input and desktop windowing.
None of that needs a rewrite. It needs a handful of habits: ask the window instead of the device, keep state out of the activity’s lifetime, and test at sizes you did not choose.
Sources
- Android 17 behavior change: restrictions on orientation and resizability are ignored
- Android Developers Blog: preparing your app for the resizability and orientation changes in Android 17
- Notebookcheck: Android 17 Beta 3 fully enables desktop-style multitasking
- Android Central: Android 17 Beta 3 brings desktop multitasking
- Compose testing reference: TrackpadInjectionScope
- Track touch and pointer movements (touch slop)
📱 Crack Your Next Android Interview
If you’re targeting a senior Android role at a FAANG or top-tier MNC, syntax knowledge alone won’t get you through the loop. I highly recommend “Cracking Top MNC Android Interviews” — a senior-level playbook covering framework internals, Jetpack Compose, coroutines, Android-specific system design, and DSA reframed around real mobile constraints, to help you walk into bar-raiser rounds ready.
- E-book: Available on Google Play
- Kindle Edition: Available on Amazon
- Topmate: Available on Topmate
- Also available in Paperback & Hardcover.







Top comments (0)