继承自CoordinatorLayout.Behavor<View>
2种方式:
1.以CoordintoeLayout的滑动距离来改变View的大小,位置,状态等
(需重写2个方法 --->
1.public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull View child, @NonNull View directTargetChild, @NonNull View target, int axes, int type) 这个方法表示为 滑动的状态监听, 默认是返回false 其中axex 返回 1 表示为横向滑动 2 表示为垂直滑动 ,这个方法的返回值必须返回true下面的方法才可以生效
2.public void onNestedPreScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull View child, @NonNull View target, int dx, int dy, @NonNull int[] consumed, int type)这个方法表示为滑动距离的监听)
2.以特定的View来作为依赖,改变View的大小,位置,状态等.
(需重写2个方法--->
1. public boolean layoutDependsOn(@NonNull CoordinatorLayout parent, @NonNull View child, @NonNull View dependency) 其中 dependency 表示你以什么View作为依赖 写法为: return dependency instanceof RecyclerView ; 表示为RV作为依赖
2.public boolean onDependentViewChanged(@NonNull CoordinatorLayout parent, @NonNull View child, @NonNull View dependency) 其中dependency 就是上面你依赖的RV)