afollestad afollestad - 1 year ago 100
Android Question

Android 4.4 — Translucent status/navigation bars — fitsSystemWindows/clipToPadding don't work through fragment transactions

When using the translucent status and navigation bars from the new Android 4.4 KitKat APIs, setting

to a
works initially.
keeps the list under the action bar and above the navigation bar,
allows the list to scroll under the transparent navigation bar and makes the last item in the list scroll up just far enough to pass the navigation bar.

However, when you replace the content with another
through a
the effect of
goes away and the fragment goes under the action bar and navigation bar.

I have a codebase of demo source code here along with a downloadable APK as an example: To see what I'm talking about, open the demo app from a device running KitKat, tap an item in the list (which will open another activity), and tap an item in the new activity that opens. The fragment that replaces the content goes under the action bar and clipToPadding doesn't work correctly (the navigation bar covers the last item in the list when you scroll all the way down).

Any ideas? Any clarification needed? I posted the before and after screenshots of my personal app being developed for my employer.


Answer Source

I solved the issue by using the library I use the set the color of my translucent status bar.

The SystemBarConfig class of SystemBarTint (as seen here lets you get insets which I set as the padding to the list in every fragment, along with the use of clipToPadding="false" on the list.

I have details of what I've done on this post:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download