Transparent navigation without displaying a layout under the status bar

I am using the new Android 4.4 flag FLAG_TRANSLUCENT_NAVIGATIONto flip the navigation bar (back, home button, etc.) at the bottom of the screen translucent. This works great, but a side effect of this is that the layout of my activity now appears below the status bar at the top of the screen (although I did not set the status bar as translucent). I want to avoid a hacker fix Ie by applying a pad to the top of the layout.

Is there a way to set the navigation as translucent, while the normal status bar is displayed normally and does NOT allow the layout to display below it?

The code I use is as follows:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    Window w = getWindow();
    w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}

thanks

+4
2

ianhanniballake , android:fitsSystemWindows="true" . :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/colorPrimaryDark">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="#ffffff"
        android:fitsSystemWindows="true">

        <!-- Your other views -->

    </LinearLayout>
</LinearLayout>

, .

+6

android:fitsSystemWindows="true" - android: fitsSystemWindows , , .

+1

All Articles