· 5 min read

Android 16 Edge-to-Edge: Fix Insets Before Targeting API 36

Android 16 removes the edge-to-edge opt-out for apps that target API 36. How to find and fix inset bugs in Views and Compose before you bump targetSdk.

Android 16 edge-to-edge is not optional any more. When an app targets API 36, the system draws it behind the status bar and the navigation bar, and the old escape hatch, windowOptOutEdgeToEdgeEnforcement, stops working. Google Play now requires API 36 for app updates, so every Android team hits this sooner or later. The change looks cosmetic. It is not: a toolbar under the clock, a button under the gesture bar or a text field under the keyboard can block a real user flow. This post is the order I use to fix insets before I bump targetSdk.

I work on the native Android app at Gatewise, a smart access control app. When the main action of a screen is a button, a button hidden behind the navigation bar is not a style issue. So I treat the target SDK bump as a small feature with its own checklist, not as a one-line change in build.gradle.

What changed in Android 16 edge-to-edge

The change came in two steps.

So if your team bought time with the opt-out last year, that time is over. The official Android 16 behavior changes page lists it next to other changes, like predictive back and the large-screen orientation rules. Edge-to-edge is the one that touches almost every screen, so I fix it first and alone.

Step 1: Find every screen that needs insets

Before writing any code, I make a list. Bumping targetSdk on a branch and clicking through the app shows the problems fast. I look for four kinds of bugs:

  1. Top bars that slide under the status bar or the camera cutout.
  2. Bottom content: buttons, bottom sheets and the last item of a list hidden behind the navigation bar.
  3. Text fields that the keyboard covers. With edge-to-edge, adjustResize no longer moves your layout for you.
  4. Custom views with hard-coded top or bottom margins that someone added years ago to "fix" the status bar.

I check each screen twice: once with gesture navigation and once with three-button navigation. The bottom inset is very different between the two, and a screen that looks fine with one often breaks with the other. Landscape and a device with a camera cutout add two more passes for the main flows.

Step 2: Fix insets in View-based screens

For XML layouts, call enableEdgeToEdge() in the activity, then apply insets as padding on the view that needs them. Do not apply them to the root of every screen by reflex. A list should scroll behind the navigation bar and only pad its last item, not shrink.

class ListActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        enableEdgeToEdge()
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_list)

        val toolbar = findViewById<View>(R.id.toolbar)
        val list = findViewById<RecyclerView>(R.id.list)

        ViewCompat.setOnApplyWindowInsetsListener(toolbar) { v, insets ->
            val bars = insets.getInsets(
                WindowInsetsCompat.Type.systemBars() or
                    WindowInsetsCompat.Type.displayCutout()
            )
            v.updatePadding(top = bars.top, left = bars.left, right = bars.right)
            insets
        }

        ViewCompat.setOnApplyWindowInsetsListener(list) { v, insets ->
            val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.updatePadding(bottom = bars.bottom)
            insets
        }
    }
}

Set android:clipToPadding="false" on the RecyclerView. Then the list draws behind the navigation bar while it scrolls, and the last item still stops above it.

Two rules save time here:

Step 3: Fix insets in Compose screens

Compose makes this easier, because insets are just modifiers. If you use Scaffold, it passes the system bar insets to its content as innerPadding. The common bug is to ignore that parameter.

@Composable
fun ItemsScreen(items: List<Item>, onOpen: (Item) -> Unit) {
    Scaffold(
        topBar = { TopAppBar(title = { Text("Items") }) },
    ) { innerPadding ->
        LazyColumn(
            contentPadding = innerPadding,
            modifier = Modifier.fillMaxSize(),
        ) {
            items(items) { item -> ItemRow(item, onOpen) }
        }
    }
}

Passing innerPadding as contentPadding, not as a Modifier.padding, keeps the same "scroll behind the bar" effect as clipToPadding="false" in Views.

For screens without a Scaffold, use the inset modifiers directly. For a form with a text field and a button at the bottom, the keyboard is the important one:

Column(
    modifier = Modifier
        .fillMaxSize()
        .safeDrawingPadding()
        .imePadding()
) {
    // fields...
    Spacer(Modifier.weight(1f))
    Button(onClick = onSubmit, modifier = Modifier.fillMaxWidth()) {
        Text("Save")
    }
}

safeDrawingPadding() covers the system bars and the cutout. imePadding() moves the button above the keyboard. Apply each inset only once in the tree. If a parent already added the system bar padding, a child that adds it again gets a double gap.

Step 4: Keep it from coming back

Fixing every screen once is not enough. The next new screen will forget the insets unless something catches it.

The target SDK bump itself goes in a separate pull request, after the inset fixes are merged. If something breaks after release, it is clear which change caused it, and the fixes do not depend on the bump. They work on older Android versions too.

Takeaways

If you also work with Kotlin on Android, my post on Kotlin Flow for BLE responses covers another Android pattern from the same app.