AppBarLayout - 一旦进入视图,布局有时是不可见的(即使它没有进入)

AppBarLayout - Layout sometimes invisible once it enters view (even if it's not entered)

我有一个问题,有时当您使用 AppBarLayout 时,它不会一直显示其全部内容:

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


    <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>


    <android.support.design.widget.AppBarLayout
            android:orientation="vertical"
            android:layout_height="148dp"
            android:layout_width="match_parent">

        <android.support.design.widget.TabLayout
                app:layout_scrollFlags="scroll|enterAlways"
                android:layout_height="48dp"
                android:background="@color/primarycolor"
                .../>

        <RelativeLayout
                app:layout_scrollFlags="scroll|enterAlways"
                android:background="@color/white"
                android:layout_height="100dp"
                ...>
        </RelativeLayout>

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

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

提供的解决方案是

但是:它提供的整行颜色与我在底部布局中指定的原色不同,因为它的背景是白色。想法?

这是对上面提供的解决方案的扩展: 使用它而不是提供的那个,它将混合 appbarlayout 和它下面的细微阴影高度。

<View
    android:id="@+id/appbar_bottom"
    android:layout_width="match_parent"
    android:layout_height=".3dp"
    android:background="#606060"
    android:visibility="visible"/>

以及由此产生的布局:

<android.support.design.widget.AppBarLayout
        android:orientation="vertical"
        android:layout_height="148.3dp"
        android:layout_width="match_parent">

    <android.support.design.widget.TabLayout
            app:layout_scrollFlags="scroll|enterAlways"
            android:layout_height="48dp"
            android:background="@color/primarycolor"
            .../>

    <RelativeLayout
            app:layout_scrollFlags="scroll|enterAlways"
            android:background="@color/white"
            android:layout_height="100dp"
            ...>
    </RelativeLayout>

    <View
        android:id="@+id/appbar_bottom"
        android:layout_width="match_parent"
        android:layout_height=".3dp"
        android:background="#606060"
        android:visibility="visible"/>
</android.support.design.widget.AppBarLayout>