-
public final class RecyclerViewContentBehavior extends CoordinatorLayout.Behavior<View>
布局中嵌套RecyclerView,并且内容随着RecyclerView滚动而滚动的,类似BottomSheetDialog的Behavior
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classRecyclerViewContentBehavior.Companionpublic interfaceRecyclerViewContentBehavior.OnDragStateListener
-
Field Summary
Fields Modifier and Type Field Description private ObjectAnimatorstateAnim
-
Constructor Summary
Constructors Constructor Description RecyclerViewContentBehavior(Context context, AttributeSet attrs)
-
Method Summary
Modifier and Type Method Description final ObjectAnimatorgetStateAnim()final UnitsetStateAnim(ObjectAnimator stateAnim)final UnitsetOnDragStateListener(RecyclerViewContentBehavior.OnDragStateListener listener)BooleanonInterceptTouchEvent(CoordinatorLayout parent, View child, MotionEvent ev)BooleanonMeasureChild(CoordinatorLayout parent, View child, Integer parentWidthMeasureSpec, Integer widthUsed, Integer parentHeightMeasureSpec, Integer heightUsed)BooleanonLayoutChild(CoordinatorLayout parent, View child, Integer layoutDirection)final IntegergetScreenHeight(Context context)BooleanonStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, Integer axes, Integer type)当coordinatorLayout 的子View视图开始嵌套滑动的时候被调用。 当返回值为true的时候表明 coordinatorLayout 充当nested scroll parent 处理这次滑动 需要注意的是只有当返回值为true的时候,Behavior 才能收到后面的一些nested scroll 事件回调(如:onNestedPreScroll、onNestedScroll等) 这个方法有个重要的参数axes,表明处理的滑动的方向。 UnitonNestedPreScroll(CoordinatorLayout coordinatorLayout, View child, View target, Integer dx, Integer dy, IntArray consumed, Integer type)嵌套滚动发生之前被调用 在nested scroll child 消费掉自己的滚动距离之前,嵌套滚动每次被nested scroll child 更新都会调用onNestedPreScroll。注意有个重要的参数consumed,可以修改这个数组表示你消费 了多少距离。假设用户滑动了100px,child 做了90px 的位移,你需要把 consumed[1]的值改成90, 这样coordinatorLayout就能知道只处理剩下的10px的滚动。 BooleanonNestedPreFling(CoordinatorLayout coordinatorLayout, View child, View target, Float velocityX, Float velocityY)UnitonStopNestedScroll(CoordinatorLayout coordinatorLayout, View child, View target, Integer type)final UnitsetState(Integer state)设置状态,并根据状态设置布局位置 final UnitsetStateAnim(View child, Float endL, Integer state)final UnitmoveViewAnim(View child, Float endL)-
Methods inherited from class com.lyy.keepassa.widget.RecyclerViewContentBehavior
blocksInteractionBelow, getInsetDodgeRect, getScrimColor, getScrimOpacity, layoutDependsOn, onApplyWindowInsets, onAttachedToLayoutParams, onDependentViewChanged, onDependentViewRemoved, onDetachedFromLayoutParams, onNestedFling, onNestedPreScroll, onNestedScroll, onNestedScroll, onNestedScroll, onNestedScrollAccepted, onNestedScrollAccepted, onRequestChildRectangleOnScreen, onRestoreInstanceState, onSaveInstanceState, onStartNestedScroll, onStopNestedScroll, onTouchEvent -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
RecyclerViewContentBehavior
RecyclerViewContentBehavior(Context context, AttributeSet attrs)
-
-
Method Detail
-
getStateAnim
final ObjectAnimator getStateAnim()
-
setStateAnim
final Unit setStateAnim(ObjectAnimator stateAnim)
-
setOnDragStateListener
final Unit setOnDragStateListener(RecyclerViewContentBehavior.OnDragStateListener listener)
-
onInterceptTouchEvent
Boolean onInterceptTouchEvent(CoordinatorLayout parent, View child, MotionEvent ev)
-
onMeasureChild
Boolean onMeasureChild(CoordinatorLayout parent, View child, Integer parentWidthMeasureSpec, Integer widthUsed, Integer parentHeightMeasureSpec, Integer heightUsed)
-
onLayoutChild
Boolean onLayoutChild(CoordinatorLayout parent, View child, Integer layoutDirection)
-
getScreenHeight
final Integer getScreenHeight(Context context)
-
onStartNestedScroll
Boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, Integer axes, Integer type)
当coordinatorLayout 的子View视图开始嵌套滑动的时候被调用。 当返回值为true的时候表明 coordinatorLayout 充当nested scroll parent 处理这次滑动 需要注意的是只有当返回值为true的时候,Behavior 才能收到后面的一些nested scroll 事件回调(如:onNestedPreScroll、onNestedScroll等) 这个方法有个重要的参数axes,表明处理的滑动的方向。
- Parameters:
coordinatorLayout- 和Behavior 绑定的View的父CoordinatorLayoutchild- 和Behavior 绑定的Viewtarget- 滚动的viewaxes- 嵌套滑动 应用的滑动方向,看 {@link ViewCompat#SCROLL_AXIS_HORIZONTAL}, {@link ViewCompat#SCROLL_AXIS_VERTICAL}
-
onNestedPreScroll
Unit onNestedPreScroll(CoordinatorLayout coordinatorLayout, View child, View target, Integer dx, Integer dy, IntArray consumed, Integer type)
嵌套滚动发生之前被调用 在nested scroll child 消费掉自己的滚动距离之前,嵌套滚动每次被nested scroll child 更新都会调用onNestedPreScroll。注意有个重要的参数consumed,可以修改这个数组表示你消费 了多少距离。假设用户滑动了100px,child 做了90px 的位移,你需要把 consumed[1]的值改成90, 这样coordinatorLayout就能知道只处理剩下的10px的滚动。
- Parameters:
dx- 用户水平方向的滚动距离dy- 用户竖直方向的滚动距离, 小于0:往下滑动
-
onNestedPreFling
Boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, View child, View target, Float velocityX, Float velocityY)
-
onStopNestedScroll
Unit onStopNestedScroll(CoordinatorLayout coordinatorLayout, View child, View target, Integer type)
-
setStateAnim
final Unit setStateAnim(View child, Float endL, Integer state)
-
moveViewAnim
final Unit moveViewAnim(View child, Float endL)
-
-
-
-