CollapsingToolbarLayout中的ImageView没有覆盖全高?

nat*_*rio 5 android android-layout android-design-library androiddesignsupport

我试图实现新的一些问题CollapsingToolbarLayout.滚动,扩展和折叠确实可以正常工作,但是我ImageView(无论我设置的资源类型)都没有覆盖扩展工具栏的整个高度.看这里:

扩大 倒塌

在这里我设置android:src="@color/red"了图像视图,但它从未覆盖真正的工具栏.它也不适用于位图.我在下面发布我的布局.

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <!-- content -->
    <android.support.design.widget.CoordinatorLayout
        android:fitsSystemWindows="true"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.design.widget.AppBarLayout
            android:layout_height="@dimen/appbar_expanded_height"
            android:layout_width="match_parent"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            android:fitsSystemWindows="true">
            <android.support.design.widget.CollapsingToolbarLayout
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"
                app:expandedTitleMarginStart="48dp"
                app:expandedTitleMarginEnd="64dp"
                app:contentScrim="?attr/colorPrimary"
                android:fitsSystemWindows="true">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fitsSystemWindows="true"
                    android:src="@color/red_600"
                    android:scaleType="centerCrop"
                    app:layout_collapseMode="parallax"
                    />
                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    app:layout_collapseMode="pin"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize">
                </android.support.v7.widget.Toolbar>

            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>

        <!-- I load fragments here -->
        <FrameLayout
            android:id="@+id/fragment_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    </android.support.design.widget.CoordinatorLayout>

    <!-- nav drawer -->
    <fragment
        android:layout_width="@dimen/drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

在我看来,与奶酪-Chris Banes-app的唯一区别在于,我正在给予app:layout_behavior一个FrameLayout.但是,在该框架内,我加载了具有NestedScrollView作为根视图的片段,这似乎工作正常.

小智 7

我有同样的问题,折叠工具栏没有覆盖图像的整个高度,但固定从删除单行AppBarLayout.那就是你只需要删除就android:fitsSystemWindows="true可以了.

<android.support.design.widget.AppBarLayout
        android:layout_height="@dimen/appbar_expanded_height"
        android:layout_width="match_parent"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true">
Run Code Online (Sandbox Code Playgroud)

删除最后一行,即.

 android:fitsSystemWindows="true"
Run Code Online (Sandbox Code Playgroud)

这就是它,好的去...


nat*_*rio 4

我发现蓝色条是工具栏背景。也就是说,我有:

<item name="toolbarStyle">@style/MyToolbarStyle</item>
Run Code Online (Sandbox Code Playgroud)

在我的主题中,并且:

<style name="MyToolbarStyle">
    <item name="android:background">?attr/colorPrimary</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我曾经用它来为工具栏着色colorPrimary。但是,如果您想移动到设计库,则应该摆脱它:折叠的工具栏颜色已经app:contentScrimCollapsingToolbarLayout.