DEV Community

Cover image for Edge-to-Edge and 3-Button Navigation: Fixing Clipped Compose UI
Nesim Razon
Nesim Razon

Posted on Originally published at nesimapps.com

Edge-to-Edge and 3-Button Navigation: Fixing Clipped Compose UI

After your app targets SDK 35, the system draws it behind the status bar and the navigation bar. On a gesture phone it often looks fine. On a phone with three buttons the last row can sit under the bar, or a bottom line can vanish. Here are three real bugs from my own apps, the fix for each, and the test routine I now use.

What edge-to-edge changed

Android's documentation says edge-to-edge is enforced once your app targets SDK 35 and runs on Android 15 or higher. The window then spans the whole display and draws behind the system bars. On earlier Android versions you get the same look by calling enableEdgeToEdge() in the activity. My apps target SDK 36, so on a current phone this is not optional.

  • The system does not move your content. Your layout must read the insets, the areas covered by system UI, and pad itself.
  • With enableEdgeToEdge() the gesture bar is transparent, but the three-button bar gets a translucent scrim by default.
  • So one screen can look right with gestures and wrong with three buttons: a real bar sits over your last row.

Think of it as a change of contract. Before, the system reserved the bar areas and your layout lived in what remained. Now your layout owns the whole rectangle and you decide where the safe area starts. Most clipped UI bugs are places where nobody decided.

In Compose the two modifiers you need most are statusBarsPadding() for the top and navigationBarsPadding() for the bottom. All three bugs below are small mistakes around them.

Bug 1: the bar space belonged to an ad

In Calisan Asistani, an Android app, the home and settings screens have no banner ad. They slid under the navigation bar. I added navigationBarsPadding() to the page box and thought it was done.

A few days later it happened again. The real cause: the bottom space came only from the banner, written as Banner(Modifier.navigationBarsPadding()). When the banner was never drawn, because ads were off, consent was missing or nothing had loaded, the padding disappeared with it. The content went under the soft buttons.

The fix is to take the bar space from something that always exists. I put a box with navigationBarsPadding() at the bottom of the page, and the banner lives inside that box only on the screens that show one.

  • Before: Banner(Modifier.navigationBarsPadding())
  • After: Box(Modifier.fillMaxWidth().navigationBarsPadding()) { if (showBanner) Banner() }

Then I tested every screen with ads on and with ads off. The rule is simple: if a padding is attached to an element that can be absent, move it to its parent. This bug needs a specific state, no ad, so it only shows if you test that state on purpose.

Bug 2: padding in the wrong place

In Pentolings, the settings and statistics content flowed under the navigation buttons. The memory note I keep for this says it came back after I had fixed it in other games. The cause was the order of modifiers on a scrolling column.

  • Wrong: Modifier.weight(1f).verticalScroll(state).navigationBarsPadding()
  • Right: Modifier.weight(1f).navigationBarsPadding().verticalScroll(state)

My explanation from the notes: when the padding comes after verticalScroll, it is added inside the scrolled content. The visible window of the list still reaches the bottom edge of the screen, so the content shows through behind the buttons. When the padding comes first, the window itself ends above the bar. The Pentolings screens now use the second order, for example in HelpScreen.kt and Screens.kt.

A quick check for this bug: scroll to the very end of the screen. The last item must stop fully above the bar, with a little space. If it stops behind the bar, the order is wrong.

Bug 3: a weight squeezed to zero

The settings screen of Slinglings is a column with a title, switches, buttons, a decorative desk scene and a version line. The desk scene used weight(1f) to take whatever height was left, and the version line sat below it.

When the rows above filled the screen, nothing was left for the weight. The scene shrank to zero height and the version line at the very bottom was cut off. A taller phone hid the problem, so it only showed on a small screen.

  • Before: DeskScene(Modifier.weight(1f))
  • After: verticalScroll on the column, DeskScene(Modifier.height(150.dp))

The column is now scrollable and the scene has a fixed height. If the content does not fit, the user scrolls instead of losing a line. The same commit also stopped the version line from being a hard-coded text: it reads the real version name now.

There were two ways out: give flexible items a minimum height, or make the screen scrollable. I chose scrolling plus a fixed height, because on a small phone the decorative scene is the first thing to give up.

Which inset for which job

Compose offers several inset modifiers. You do not need all of them, but it helps to know what each one answers.

  • statusBarsPadding(): keeps a top bar below the status bar.
  • navigationBarsPadding(): keeps bottom content above the navigation bar, in gesture mode and in button mode.
  • systemBarsPadding(): both of the above in one modifier.
  • imePadding(): keeps a text field above the on-screen keyboard.
  • safeDrawingPadding(): system bars, keyboard and display cutouts together.
  • Scaffold: hands you an innerPadding value. If you ignore it, the content is not padded at all.

The Android documentation also lists display cutout insets and system gesture insets. The gesture insets matter when your own swipes start near the screen edge; the docs mention swiping in games as an example. My screens mostly use the first two modifiers. I have not needed more, so I cannot tell you from experience how the others behave in every case.

Large text and longer languages

Fixed heights are risky in the other direction too. A button with a fixed height cuts its label when the user sets a larger font. In Pentolings the shared button uses heightIn(min = ...) so it can grow with the text.

In my notes for other apps I also planned to test at 1.3x and 1.5x font size, because Spanish and Portuguese labels are longer than English ones. I have not run that test on every app yet, and I do not claim it. I treat it as a checklist item, not a result.

Do the arithmetic: at a 1.3 font scale a 14 sp label is drawn at about 18 sp, so the same words need roughly 30 percent more width. A label that fit on one line may now need two, or be cut.

In the Tilelings design notes I wrote a rule for long labels: one line only, a measurement test, and a fallback to 11 sp, checked on a small phone with a 1.3x font. That is a plan from the notes, not a measured result. The same notes list 48 dp touch targets, so a button never shrinks below a finger-sized area.

The test routine

Gesture navigation hides most of these bugs, so I test with the other mode. This is the routine.

  • Use an emulator with three-button navigation (I use an Android 11 image).
  • Raise the font size to 1.3 with: adb shell settings put system font_scale 1.3 (set it back to 1.0 afterwards).
  • Open every screen, scroll to the very bottom and take a screenshot.
  • Repeat with the longest language and with a small screen.
  • Turn ads off and on, because optional elements change the layout.

Before each release I now ask three questions. Is the last item of every scrolling screen fully above the bar? Does any bottom space depend on an optional element? Does any flexible item have a fixed minimum? Each step above reproduces one bug: three buttons show bugs 1 and 2, a small screen shows bug 3, a large font shows the cut labels, and ads off shows bug 1 again.

FAQ

From which target SDK is edge-to-edge enforced?

According to the Android documentation, edge-to-edge is enforced on Android 15 (API level 35) and higher once your app targets SDK 35.

Does navigationBarsPadding() go before or after verticalScroll?

Before. Placed after, the padding scrolls with the content and the list still shows behind the navigation bar.

Why does my UI look fine on gesture navigation but break with three buttons?

With three buttons a real, translucent navigation bar covers the bottom of the window, so any content without bottom padding sits under it.

Why did my bottom line disappear on a small screen?

A weight(1f) item shrinks to zero when the other items fill the screen. Make the screen scrollable and give that item a fixed height.

Top comments (2)

Collapse
 
userxnom profile image
Abdullah Naseer •

Bug 2 is the one I'd have gotten wrong — I'd have assumed navigationBarsPadding() works the same anywhere in the modifier chain. Have you run into the same ordering trap with imePadding() inside a scrolling column, or does the keyboard resizing the window make that one more forgiving? And in your test routine, does the Android 11 emulator catch anything the 1.3x font scale run doesn't, or is it mainly there for the 3-button bar?

Collapse
 
mosmox_studio profile image
Mosmox Studio •

Bug 1 is such a good example of a layout that only breaks in one specific state. Moving the inset to something that always exists is a rule worth keeping. One trade-off with putting navigationBarsPadding() before verticalScroll: the scroll viewport ends above the bar, so content never passes behind the translucent bar. If you want the full edge-to-edge look on a LazyColumn, passing WindowInsets.navigationBars.asPaddingValues() as contentPadding lets items scroll behind the bar while the last one still stops above it.