79424962

Date: 2025-02-09 13:34:29
Score: 0.5
Natty:
Report link

android:fitsSystemWindows

If true, adjusts the padding of this view to leave space for the system windows.

You can manually do that using WindowInsetsListener.

ViewCompat.setOnApplyWindowInsetsListener(appBar) { view, windowInsets ->
    val insets = windowInsets.getInsets(WindowInsetsCompat.Type.statusBars())
    // Apply the insets as padding to the view. Here, set all the dimensions
    // as appropriate to your layout. You can also update the view's margin if
    // more appropriate.
    view.updatePadding(insets.left, insets.top, insets.right, insets.bottom)

    // Return CONSUMED if you don't want the window insets to keep passing down
    // to descendant views.
    WindowInsetsCompat.CONSUMED
}

please refer to:

https://developer.android.com/develop/ui/views/layout/edge-to-edge#system-bars-insets

https://developer.android.com/reference/android/view/View#attr_android:fitsSystemWindows

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Ibrahim Zulfiqar