带有自定义视图的可折叠工具栏随着滚动的发生而移动并固定(就像在留声机中一样)

Collapsible Toolbar with Custom View that Moves as Scrolling Happens and Gets Pinned (like in Phonograph)

我想在我的应用程序中实现类似于以下内容的功能,但我希望整个红色区域(在下面的屏幕截图中显示 "Guardians Of The Gala..." 的地方)是一个自定义视图。 (一些元素会随着工具栏的折叠而淡出。)

`` `

我已经尝试了好几个小时让它工作,但无济于事。

显然,只是将它放入 <Toolbar> 中是行不通的,因为它不知道应该为其设置动画:

<android.support.design.widget.CoordinatorLayout>
    <android.support.design.widget.AppBarLayout>
        <android.support.design.widget.CollapsingToolbarLayout>
            <ImageView/>
            <android.support.v7.widget.Toolbar>
                <include layout="@layout/link_view_title_bar"/>

我已经尝试完成 here and here 中的大部分答案,但没有任何实际效果。

我该怎么做,最好主要使用 XML 和 Android 设计支持库。如有任何帮助,我们将不胜感激。

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/homeCoordinator"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/homeAppBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/homeCollapseToolbar"
            android:layout_width="match_parent"
            android:layout_height="350dp"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">

            //This can be changed to ImageView
            <com.daimajia.slider.library.SliderLayout
                android:id="@+id/homeSliderLayout"
                app:layout_collapseMode="parallax"
                android:fitsSystemWindows="true"
                android:layout_width="match_parent"
                android:layout_height="350dp"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/homeToolbar"
                android:title=""
                android:layout_width="match_parent"
                android:layout_height="115dp"
                android:gravity="top"
                android:minHeight="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:titleMarginTop="15dp" >

                <ImageView
                    android:src="@drawable/ic_logo"
                    android:paddingLeft="10dp"
                    android:layout_gravity="center|top"
                    android:layout_width="wrap_content"
                    android:layout_height="35dp" />

            </android.support.v7.widget.Toolbar>

            //Instead of the TabLayout, put your Red Layout
            <android.support.design.widget.TabLayout
                android:id="@+id/homeTabLayout"
                android:layout_marginBottom="15dp"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_gravity="bottom"
                app:tabGravity="center"
                app:tabIndicatorColor="@color/colorAccent" />

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

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

    <android.support.v4.view.ViewPager
        android:id="@+id/homeViewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>