I have a horizontal RecyclerView in a LinearLayout with a TextView above it, for example:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="7dp"
android:textColor="#FFa7a7a7"
android:textSize="15sp"
android:text="Hello, Android" />
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="185dp" />
I want the TextView to disappear when there is a left scroll, and the first element in the RecyclerView goes out of view. And you want it to disappear during the appearance of the first element (through the right scroll). I know that I will have to use addOnScrollChangedListener()to determine when the first recyclerView goes out of view, something that I could not determine is a way to fade out (or fade out) the TextView using scroll behavior.
Here is my Java RecyclerView snippet:
mRecyclerView = (RecyclerView)rootView.findViewById(R.id.recyclerview);
mRecyclerView.setLayoutManager(getLayoutManager());
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setAdapter(mAdapter);
source
share