I am trying to hide and show the view when my recyclerview scrolls using the layout coordinator.
My view is a linearlayout with a button, and it is not a fab , toolbar or tablayout , as I already know how to hide them when scrolling.
Please note that this is not a duplicate, as all answers show how to use the toolbar or tab
This is xml, I am using
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/prodMain" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent" android:orientation="vertical" xmlns:app="http://schemas.android.com/apk/res-auto"> <RelativeLayout android:id="@+id/LinearLayout01" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/gray_light" android:orientation="vertical" android:paddingLeft="10dp" android:paddingRight="10dp"> <LinearLayout android:id="@+id/linearFilterLayout" android:layout_width="match_parent" app:layout_behavior="fc.admin.fcexpressadmin.itemdecorators.FABFloatOnScroll" android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin10dp" android:background="@color/white" android:orientation="horizontal" android:padding="@dimen/margin10dp" android:visibility="visible" android:weightSum="3"> </LinearLayout> <ViewFlipper android:id="@+id/ViewFlipper01" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/linearFilterLayout" android:layout_marginBottom="@dimen/margin10dp" android:layout_marginTop="@dimen/margin6dp" android:background="@color/gray_light" android:visibility="visible"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <Button android:id="@+id/btnFooterRefresh" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginTop="5dp" android:text="Refresh" android:visibility="visible"/> <android.support.v7.widget.RecyclerView android:id="@+id/gridview" android:layout_width="match_parent" android:clipToPadding="false" android:layout_height="match_parent" android:layout_above="@+id/btnFooterRefresh" android:cacheColorHint="@android:color/transparent" android:listSelector="@android:color/transparent" android:scrollbars="vertical" android:scrollingCache="false" android:visibility="visible"/> </RelativeLayout> </ViewFlipper> </RelativeLayout> </LinearLayout> </android.support.design.widget.CoordinatorLayout>
and this is the code of my user behavior:
public class FABFloatOnScroll extends CoordinatorLayout.Behavior { private static final Interpolator INTERPOLATOR = new FastOutSlowInInterpolator(); private int mDySinceDirectionChange=0; public FABFloatOnScroll() { super(); } public FABFloatOnScroll(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) { Log.e("scroll", "dependent on views"); return dependency instanceof LinearLayout; } @Override public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
But the problem is that the custom behavior class does not trigger any logs that print at all
android android-coordinatorlayout androiddesignsupport
Cold fire
source share