androidandroid-jetpack-composematerial3android-15edge-to-edge

System bar paddings are not applied to FloatingActionButton in landscape orientation - how to fix it?


System bar paddings are not applied to FloatingActionButton in landscape orientation even though composable is placed into Scaffold and contentWindowInsets of Scaffold set to WindowInsets.safeDrawing. System bar paddings are applied only in portrait orientation. I'm trying to support edge-to-edge enforcement.

My compose-bom version: 2025.05.00. I'm using Material3.

Here is my example code:

Activity:

override fun onCreate(savedInstanceState: Bundle?) {
 ...
 enableEdgeToEdge()
 ...
 setCotent {
  Scaffold(
   floatingActionButton = {
    FloatingActionButton(
     onClick = {}
    ) {
     Icon(...)
    }
   },
   contentWindowInsets = WindowInsets.safeDrawing
  ) {
   ...
  }
 }
}

Here is the result:

enter image description here


Solution

  • This is a known bug: https://issuetracker.google.com/issues/244400727.

    Current workaround is to apply inset paddings manually to FloatingActionButton in landscape orientation.

    override fun onCreate(savedInstanceState: Bundle?) {
     ...
     enableEdgeToEdge()
     ...
     setCotent {
      Scaffold(
       floatingActionButton = {
        FloatingActionButton(
         onClick = {},
         modifier = if (LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE) Modifier.windowInsetsPadding(WindowInsets.safeDrawing) else Modifier
        ) {
         Icon(...)
        }
       },
       contentWindowInsets = WindowInsets.safeDrawing
      ) {
       ...
      }
     }
    }
    

    The result:

    enter image description here