Search code examples
androidandroid-support-libraryandroid-constraintlayoutandroid-statusbar

fitsSystemWindows ignored by ConstraintLayout


I am trying to show make an activity in my app where the statusbar is completely transparent. I added this to my style:

<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>

But for some reason all views in my are all appearing below the statusbar. All the views are top aligned to parent app:layout_constraintTop_toTopOf="parent".

enter image description here


Solution

  • I fixed it by adding the following code to my activity:

    Window w = getWindow();
    w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);