Translucent system bars and content margin in KitKat

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.

  • Are there any built-in/default sounds that can be utilized in an App?
  • Is there an Android Material Design onboarding/tutorial overlay/showcase library?
  • How to accept bluetooth received file in Android application?
  • ActivityNotFoundException while sending email from the application
  • How to get the timezone offset in GMT(Like GMT+7:00) from android device?
  • FileNotFoundException for HttpURLConnection in Ice Cream Sandwich
  • 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?

    Related posts:

    Disabling of EditText in android
    android: command not found
    How to shrink a finishing activity to a rectangle
    How do I rotate the Android emulator display?
    SHA-1 fingerprint of keystore certificate
    Android decoder->decode returned false for Bitmap download
  • Can't perform Sync (onPerformSync is not called)
  • How to define and use a system property in Android Instrumentation test?
  • Android Studio - “aidl is missing”… no, it's not
  • Seek bar, change path color from yellow to white
  • Shared Preferences vs Database
  • listView dynamic add item
  • 5 Solutions collect form web for “Translucent system bars and content margin in KitKat”

    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.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.