android – Translucent system bars and content margin in KitKat-ThrowExceptions

Exception or error:

I’m trying to take advantage of the new KitKat translucent system bars, to get a full screen image in the background of my app.

I’m having problems figuring out the right settings to get the behaviour I want. Right now I have a ViewPager with three Fragments each one composed of a RelativeLayout containing an ImageView (for the background image) and a TextView for the content.

What I’m after is to have the content fit fully in the portion of the screen available for interactions, and the image to take the whole visible portion of the screen.

If I just use android:Theme.Holo.Light.NoActionBar.TranslucentDecor as my theme it looks fine in portrait, but the navigation bar overlaps the content in landscape (see the screenshots below).

First attempt - portrait. Looks good.First attempt - landscape. nav bar overlaps the content

Following the recommendation in the docs, I added android:fitsSystemWindows = true to my theme, but that generates some weird artifacts (see below)
Second attempt - portrait. Artifacts!!
Second attempt - landscape. Artifacts!!

How can I make it behave like in the second example, but look good, without the visual artifacts?

How to solve:

I know this is old, but I’ve just run into the same problem and found an easy solution, so I wanted to share it in case this was run into by anyone Google’ing around.

It seems that there is an Android bug when a ViewPager (especially an ImageSwitcher) is placed within a layout that has the attribute android:fitsSystemWindows="true". For some reason the system windows seem to be getting artifacts drawn all over them. :/

Anyway, I found a fix. For my activity, I had an XML layout as follows:

<FrameLayout xmlns:android=""
    <!-- NOT HERE! android:fitsSystemWindows="true" -->




        android:fitsSystemWindows="true" <!-- Here!!! -->

        <!-- Fitted content here -->


The trick was to not contain the ImageSwitcher in a layout with the android:fitsSystemWindows="true" attribute, but to instead move the android:fitsSystemWindows="true" attribute to the inner FrameLayout containing the actual content I needed to fit (the title text in your case). Unfortunately, this allows for the ImageSwitcher/ViewPager’s view to get slightly cut off by the system windows, but if the image is used like a background image anyway it doesn’t matter too much and is a much better trade off than artifacts or maintaining all of the different dimensions/styles that may or may not have disabled navigation (such as the currently selected answer).

I hope this helps someone!


My solution was to disable translucent navigation in landscape mode. You still get a translucent status bar, but it fixes the issue where the nav bar is opaque and overlaps in landscape.

res/values-v19/styles.xml (these values are in my theme)

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">@bool/translucentNavBar</item>

res/values-v19/bools.xml (enable translucent nav)

<bool name="translucentNavBar">true</bool>

res/values-land-v19/bools.xml (disable translucent nav in landscape)

<bool name="translucentNavBar">false</bool>

res/values-sw600dp-land-v19/bools.xml (enable translucent nav for tablets in landscape)

<bool name="translucentNavBar">true</bool>


I’ve run into similar problems, but I wasn’t using a ViewPager, so this may not work. I solved by doing some nesting as Gabe described: only the inner ViewGroup is fitSystemWindows=”true”, the outer ViewGroup which displays the background is therefore allowed to extend under the translucent bars. Then I’m also calling requestFitSystemWindows() on orientation changes. Again, your ViewPager might be complicating things and my solution won’t work, but I hope this helps.


Put another ViewGroup inside of the one with the image and fitsSystemWindows to true


You should wrap this inside an Linear Layout and set fitsSystemWindows to true.

Leave a Reply

Your email address will not be published. Required fields are marked *