What is the XML property fitSystemWindows (android) for?

android:fitsSystemWindows = true

On several occasions I have come across this property for the preparation of layouts, however on many occasions this same cause unexpected behavior, which take time to identify that this causes it.

Definition obtained from the official site:


Boolean internal attribute to adjust view based on windows system such as the status bar.

What I understand is that this property makes my layout cover the whole screen, but I have seen it implemented in different places and I do not see exactly what function it plays or if it can be dispensed with.

asked by dámazo 21.10.2017 в 07:05

2 answers


By means of the fitsSystemWindows attribute, we get that <NavigationDrawer> or Cajón does not hide the status bar and looks below the system status bar ' will make that part translucent or transparent '. As of API 21 ' Android 5.0 ' or higher.

answered by 14.02.2018 в 19:04

To understand a little more about this property, imagine that you have a status bar (status bar) and below a list, when you add a ListView the first element may not be visible, since the status bar is shows above the ListView, to avoid this problem and precisely through the property

android:fitsSystemWindows = true

The system windows are the parts of the screen where the system draws non-interactive content (status bar).

Most of the times, our application will not need to draw below the status bar or the navigation bar, but if it does, it must be ensured that the elements are not hidden below. That's what the default behavior of the android attribute offers:

android:fitsSystemWindows = "true "

It establishes a padding (padding) of the view to guarantee that the contained elements do not overlap the windows of the system.

answered by 21.10.2017 в 14:47