My application* was heavily dependent on fantastic ObservableScrollView for scrolling techniques proposed in Material Design guidelines. With the release of design support library I thought of branching my codebase and starting having fun replacing ObservableScrollView library with support design library.

In my PreviewActivity which works as details activity I had simple ObservableScrollView which hosted header image at the top and some content down on. On top of this I had this Toolbar, of course, for navigation and menu options. Toolbar background drawable supposed to be translucent when the header image is completely visible.

Translucency was decreasing as the header which was flexible scroll space was shrinking. This should be the logic in words behind the old ways with this library. :)

Layout & Behavior

I had to port same logic and layout in terms of CoordinatorLayout.Behavior without involving CollapsingTitleLayout. Nevertheless, I had to wrap up the header image in AppBarLayout, replace ObservableScrollView with NestedScrollView, add Toolbar as direct child of CoordinatorLayout, so the Behavior works and all this in CoordinatorLayout. Easy as breeze:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/preview_top_parent"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout...>

<android.support.v4.widget.NestedScrollView ...> <android.support.v7.widget.Toolbar

...

app:layout_behavior=".view.ToolbarBackgroundAlphaBehavior"/> </android.support.design.widget.CoordinatorLayout>

For the sake of consistency header image was still scrolling range, with which I had to manipulate Toolbar background drawable alpha.

Toolbar alpha behaviour is dependant on AppBarLayout, therefore: