FitsSystemWindows on API16 device not working

My activity requests a full-screen layout:

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

and in the xml layout, the fitsSystemWindows property adds the height of the status bar:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

<!-- The main content view -->

        <android.support.design.widget.CoordinatorLayout
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/main_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true">

            <android.support.design.widget.AppBarLayout
                android:id="@+id/appbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true">

                <android.support.design.widget.CollapsingToolbarLayout
                    android:id="@+id/collapsing_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
                    app:contentScrim="@color/actionbar_title_color"
                    android:fitsSystemWindows="true">

Compiled with help appcompat-v7:23.2.1, it works well on the API21 device, but the gasket is not applied on the API16 device . Any clues?

UPDATE

Bounty on: why isnโ€™t the extension used on the API16 device?

+4
source share
1 answer

From white paper Android development template

KitKat fitSystemWindows() - return true, false, .

Lollipop API . onApplyWindowInsets(), View , , dispatchApplyWindowInsets() .

, Lollipop, ViewCompat.setOnApplyWindowInsetsListener(), onApplyWindowInsets(). ViewCompat onApplyWindowInsets() dispatchApplyWindowInsets() .

, api ,

if(API < Kitkat){
    fitSystemWindows()
}else if(API > Lollipop){
    onApplyWindowInsets()
}

. .

http://developer.android.com/reference/android/view/View.html#fitSystemWindows%28android.graphics.Rect%29

-1

All Articles