In my theme I defined the following rules to draw my views behind the status bar:
- @android:color/transparent
for me the problem was that the keypad hides an editText field which is placed at the end of the activity ..I have tried every solution out there and nothing works.
I was using this code before the call to setContentView()
method to make the status bar transparent:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); // in Activity's onCreate() for instance
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
I removed it and also removed android:windowSoftInputMode="adjustResize|adjustPan" from the maneifest
file and now it works.
There is an easy way to do this. Make sure you set the 2 elements in styles of the theme applied to your activity.
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
....
<item name="colorPrimaryDark">@android:color/transparent</item>
<item name="android:fitsSystemWindows">true</item>
...
</style>
No need to do add android:fitsSystemWindows
in your layout. This will directly add to it.
Make this changes
1. Manifest - create a theme and add window background of your like
2. toolbar in xml - add the same background in toolbar
this works for me.
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>
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.