Android:fitsSystemWindows Not Working


Answer :

Use CoordinatorLayout as root for your view, it worked for me.

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> 

My problem was most likely related to multiple/nested fitsSystemWindows attributes which does not work as I found out later. I solved my problem by applying the attribute to one view, and then copy the paddings to other views that need them via an ViewTreeObserver.OnGlobalLayoutListener. That is an ugly hack, but does its job for now.


I meet the same problem in Android 4.4

My problem is <item name="android:windowTranslucentStatus">true</item>

conflict with <item name="android:fitsSystemWindows">true</item>

My way is remove <item name="android:windowTranslucentStatus">true</item>


Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android SDK Location Should Not Contain Whitespace, As This Cause Problems With NDK Tools