Compose Modifier

safeDrawingPadding

Adds padding to accommodate the safe drawing insets.

safeDrawingPaddingSample

@Sampled
fun safeDrawingPaddingSample() {
    class SampleActivity : ComponentActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            WindowCompat.setDecorFitsSystemWindows(window, false)
            super.onCreate(savedInstanceState)
            setContent {
                Box(Modifier.background(Color.Black).systemBarsPadding()) {
                    // The app content won't have anything drawing over it, but all the
                    // background not in the status bars will be white.
                    Box(Modifier.background(Color.White).safeDrawingPadding()) {
                        // app content
                    }
                }
            }
        }
    }
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: