Android Lollipop:ImageView忽略fitsSystemWindows属性(透明状态栏)

Ser*_*les 10 android imageview android-layout android-5.0-lollipop

我正在开发一个我想要启用透明状态栏的应用程序.我想要一个ImageView(我的scaleType属性需要)覆盖整个屏幕,以便图像显示在状态栏下方.这是我的布局:

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:adjustViewBounds="true"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            android:src="@drawable/picture" />

        <android.support.v7.widget.Toolbar
            (...toolbar stuff...)
        />

        (...some other stuff...)

    </RelativeLayout>

    <include layout="@layout/drawer" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

如你所见,这是一个常规的DrawerLayout.请注意DrawerLayout,the RelativeLayout和the ImageViewall都将fitsSystemWindows属性设置为true.

我的问题是:如果我设置背景资源(如颜色或图片)来完成的DrawerLayoutRelativeLayout在上面的代码中,我可以看到"下面"的状态栏的颜色或图片,正是我所想要的,但ImageView's'src'drawable总是显示在它下面,好像它fitsSystemWindows完全忽略了属性一样.

我的主题中有以下属性:

<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/primary_dark</item>
Run Code Online (Sandbox Code Playgroud)

随着primary_dark是一个半透明的黑色(这不应该怎样都无所谓,因为正如我所说,这似乎是专属我的一个问题ImageView.透明状态栏的作品完美无论是DrawerLayoutRelativeLayout.

小智 2

这对我来说非常有效

android:fitsSystemWindows="true"每个 viewGroup 参数中都有。尝试在 ImageView 中只留下一个。

或者完全删除它们。