androidandroid-jetpack-composeedge-to-edge

In Jetpack Compose, enabling enableEdgeToEdge with WindowInsets(0.dp) glitches statusbar padding at start


While rendering the first frame of an edge-to-edge application with Jetpack Compose, the height of the statusbar is ignored, resulting in jerking of UI. How to solve this?

First vs next frames:

This image shows glitching of the main content, but beyond this, the TopAppBar itself is often rendered without indentation. This is very annoying.


Solution

  • To fix this, just add WindowInsets.safeDrawing anywhere before the UI description. The first call to this function always returns 0, the next ones work correctly.

    For example, at the very beginning of setContent:

    Or, to hide this line, inside AppTheme: