0

So I have my root activity layout (with CoordinatorLayout, ToolbarLayout, Viewpager) like so:

<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.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|enterAlways">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"/>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

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

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

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

And in one of my ViewPager's fragments I have the following layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              xmlns:tools="http://schemas.android.com/tools"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@color/white"
              android:orientation="vertical"
              tools:ignore="MissingPrefix">

    <LinearLayout
        android:id="@+id/fixedContent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical">

        <!-- SOME FIXED CONTENT -->
    </LinearLayout>

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">


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


        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#f5f5f5">

            <FrameLayout
                android:id="@+id/content"
                android:layout_width="match_parent"
                android:layout_height="360dp"
                android:minHeight="100dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <!-- SOME CONTENT THAT CHANGES W/ THE APPBAR OFFSET -->
            </FrameLayout>
        </android.support.design.widget.AppBarLayout>
    </android.support.design.widget.CoordinatorLayout>

</LinearLayout>

The issue I'm having is that when the RecyclerView is scrolled upwards only it's sibling AppBarLayout changes in size, whereas its ancestral parent AppBarLayout (holding the Toolbar) is never adjusted - where really we'd want it to be the first view to be adjusted.

Does anyone have any suggestions as to how this problem could be solved?

kassim
  • 3,880
  • 3
  • 26
  • 27
  • Maybe you need the fragment CoordinatorLayout to be the root view, out of the LinearLayouts. – natario Oct 02 '15 at 10:01
  • did you figure this one out? This is the second time someones asks this and there is no official docs on how to deal with nested CoordinatorLayouts – Atieh Jan 15 '16 at 01:58
  • @Atieh there's no support for nested CoordinatorLayouts as far as I'm aware, observing that NestedScrollingParent is implemented but not NestedScrollingChild. My solution was to implement the desired behaviour by listening to the RecyclerView scroll and adjusting an overlaying view instead. (So just a single CoordinatorLayout at the top level) – kassim Jan 17 '16 at 16:37
  • @kassim can you share what you ended up doing? – Atieh Jan 18 '16 at 15:11

0 Answers0