There's quite a bit going on when scrolling in in the My Movies screen (or in the Google Play Music app). Here's how thing basically work:
General Idea
Create a simple colored view with your actionbar color behind your RecylcerView
Add your tabs (or dummy tab, in your case) to the Toolbar
container view.
Add an OnScrollListener
to your RecyclerView
(the more difficult part). Use the dy
(delta in y-direction) to
parallax-scroll your colored view. If scrolling down, translate
the toolbar container towards the top of the screen. If scolling
up, show the toolbar container (unless it's already visible)
Code
In your activity.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Actual content (could also be in a fragment -->
<View
android:id="@+id/coloredView"
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="#CC0000" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="12dp"
android:layout_marginLeft="12dp"
android:paddingTop="120dp"
android:clipToPadding="false" />
<!-- Toolbar (container) -->
<LinearLayout
android:id="@+id/toolbar_container"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/abc_action_bar_default_height_material"
android:layout_gravity="top"
android:gravity="center_vertical"
android:background="#CC0000"
android:minHeight="0dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
style="@style/Toolbar" />
<!-- Fake tab ;) -->
<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="Dummy tab"
android:background="#CC0000"
android:padding="16dp"
android:textAllCaps="true"
android:textColor="#fff" />
</LinearLayout>
</FrameLayout>
In onCreate() of your MainActivity.java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Init your recyclerview here.
final View toolbarContainer = findViewById(R.id.toolbar_container);
final View coloredView = findViewById(R.id.coloredView);
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy < 0) {
onScrollUp(dy);
} else {
onScrollDown(dy);
}
}
private void onScrollDown(int dy) {
coloredView.setTranslationY(coloredView.getTranslationY() - dy / 3);
toolbarContainer.setTranslationY(toolbarContainer.getTranslationY() - dy);
}
private void onScrollUp(int dy) {
coloredView.setTranslationY(coloredView.getTranslationY() - dy / 3);
if (toolbarContainer.getTranslationY() < 0) {
showToolbar();
}
}
private void showToolbar() {
toolbarContainer.animate()
.translationY(0)
.setDuration(200)
.setInterpolator(new DecelerateInterpolator())
.start();
}
});
Result

(I've left out little details like the toolbar shadow or the toolbar showing its full height if it wasn't fully hidden.)
Hope that helps!
PS: The title of your question is very specific. Maybe you should change it to something like "Hiding toolbar on recyclerview scroll like in Google Play/Play Music" so that this thread is easier to find ;)