在协调器布局中隐藏工具栏下方的 textView

Hiding textView below toolbar in coordinator layout

我正在创建一个如下所示的布局:

工具栏在 main_activity 其他的在另一个 xml 文件中

当我滚动时,我想隐藏顶部工具栏和 recyclerView 之间的 textView。

为什么不尝试以下方法,它可能会有所帮助

myRecyclerview.addOnScrollListener(new RecyclerView.OnScrollListener(){
            @Override
            public void onScrolled(RecyclerView rv, int dx, int dy) {
                //boolean hasStarted = state == rv.SCROLL_STATE_DRAGGING; //Scrollbar is MOVING
                //boolean hasEnded = state == rv.SCROLL_STATE_IDLE;       //ScrollBar is NOT MOVING
                //boolean isStopping = state == rv.SCROLL_STATE_SETTLING; //Scrollbar is STOPPING
                if(dy > 0){
                   myTextview.setVisibility(View.VISIBLE);
                }
            }
        });

这是主要的 activity

<?xml version="1.0" encoding="utf-8"?>
    <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"
        >



        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            >


            <FrameLayout
                android:id="@+id/toolbar_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:layout_gravity="center"
                    app:titleMarginStart="10dp"



                <com.miguelcatalan.materialsearchview.MaterialSearchView
                    android:id="@+id/search_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"                   
                    android:inputType="textAutoCorrect"
                    app:searchBackIcon="@drawable/ic_back_arrow"
                    app:searchVoiceIcon="@drawable/ic_voice_black"
                    />

            </FrameLayout>

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