I have a layout (created by android studio) where I added a RelativeLayout to the AppBarLayout. The code is below and it looks like this:

Where I am stuck: What I want to achieve is to scroll down the Recyclerview, I want the green relative layout (which has the identifier "controlContainer") to scroll with it, and when I scroll up, it should scroll (not just from the top, but anywhere, I look through the list in the list)
The toolbar on top should remain where it is.
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true" tools:context=".MainActivity"> <android.support.design.widget.AppBarLayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:popupTheme="@style/AppTheme.PopupOverlay" /> <RelativeLayout android:id="@+id/controlContainer" android:layout_width="match_parent" android:layout_height="40dp" android:background="@android:color/holo_green_dark" app:layout_scrollFlags="scroll|enterAlways"></RelativeLayout> </android.support.design.widget.AppBarLayout> <FrameLayout android:id="@+id/frameLayout" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <include layout="@layout/venue_list" /> </FrameLayout>
I thought that using app:layout_scrollFlags="scroll|enterAlways"
in a view that should scroll together in app:layout_behavior="@string/appbar_scrolling_view_behavior"
should achieve this, but does nothing. alternatively, when I add these fields to the toolbar, both layouts scroll - this is not what I want, I want the toolbar to remain unchanged.
would it be nice if someone could point me in the right direction here? (I was hoping this would be possible using the coordinator layout and not hack the layout using onscroll listeners?)
source share