Android window insets, the soft keyboard, and edge-to-edge
androidcomposeinsetsimeedge-to-edgewindowSoftInputMode
How an app's layout reacts to the on-screen keyboard and the system bars depends on windowSoftInputMode, inset handling, and (since Android 15) mandatory edge-to-edge. Three real bugs show the traps.
Compose app: whole screen pans off when the keyboard opens
Symptom: opening the keyboard shoved the compose bar to the top, with the app bar and messages gone and a keyboard-height dead strip above the IME. It looked like a Compose layout bug; it was not.
- With no
windowSoftInputModein the manifest,adjustUnspecifiedresolves to adjustPan for Compose-only windows (the framework cannot see a scrollable View insideComposeView). The window panned up by the keyboard height whileimePadding()also padded: double compensation. - Fix:
android:windowSoftInputMode="adjustResize"on every activity with text input. With enforced edge-to-edge it does not actually resize, it just stops the pan. - Also call
.consumeWindowInsets(paddingValues)before.imePadding(), or the navigation-bar inset stacks under the IME height and leaves a nav-bar-sized gap. - Diagnose:
adb shell dumpsys window windows | grep -A6 "Window #.*<package>"and readsim={adjust=...}. Reproduce withadb shell input tapplus screencaps before and after. - When switching pan to resize, every screen with a text field needs
imePadding; dialogs and sheets handle the IME themselves.
View-based app on Android 15: bars cover the UI
targetSdk 35 on Android 15 enforces edge-to-edge. Activities built from plain view trees with no inset handling had translucent system bars over their content, and the theme's ActionBar buried the app's own toolbar. Fix: a helper that pads the root by systemBars | displayCutout | ime insets, a NoActionBar theme, dark bar icons where needed. Put the padding on an outer shell view, not on a root whose padding other code also sets, or the listener clobbers it.
Input method views
An IME that rebuilds its input view (for example on a theme change) must call requestApplyInsets() on the new view, or its bottom row sits under the navigation bar.
On Android 15+ the IME window is also edge-to-edge and must pad itself above the navigation bar. Some OEM builds misreport that inset: on a OnePlus (OxygenOS, 3-button navigation) the keyboard's space-bar row was sometimes hidden behind the nav bar because systemBars() insets came back as 0 (bars "hidden") while the bar was drawn. Robust version: pad by the max of the visible systemBars | displayCutout bottom inset and getInsetsIgnoringVisibility(navigationBars()), and re-apply rootWindowInsets plus requestApplyInsets() in onWindowShown() on every show. On the emulator, cmd overlay enable com.android.internal.systemui.navbar.threebutton switches to 3-button navigation for testing.