getInsetDodgeRect

This method allows a behavior to update the rectangle that should be dodged.
The rectangle should be in the parent's coordinate system and within the child's
bounds. If not, a IllegalArgumentException is thrown.

Parameters

parent

CoordinatorLayout: the CoordinatorLayout parent of the view this Behavior is
associated with

child

V: the child view of the CoordinatorLayout this Behavior is associated with

Note that if a Behavior changes the layout of a child via this method, it should
also be able to reconstruct the correct position in
onLayoutChild.
onDependentViewChanged will not be called during normal layout since
the layout of each child view will always happen in dependency order.

If the Behavior changes the child view's size or position, it should return true.
The default implementation returns false.

Parameters

parent

CoordinatorLayout: the parent view of the given child

child

V: the child view to manipulate

dependency

View: the dependent view that changed

Returns

boolean

true if the Behavior changed the child view's size or position, false otherwise

onDetachedFromLayoutParams

Called when the Behavior has been detached from its holding LayoutParams instance.

This will only be called if the Behavior has been explicitly removed from the
LayoutParams instance via setBehavior(Behavior). It will not be
called if the associated view is removed from the CoordinatorLayout or similar.

onInterceptTouchEvent

Respond to CoordinatorLayout touch events before they are dispatched to child views.

Behaviors can use this to monitor inbound touch events until one decides to
intercept the rest of the event stream to take an action on its associated child view.
This method will return false until it detects the proper intercept conditions, then
return true once those conditions have occurred.

This method will be called regardless of the visibility of the associated child
of the behavior. If you only wish to handle touch events when the child is visible, you
should add a check to isShown() on the given child.

The default implementation of this method always returns false.

Parameters

parent

CoordinatorLayout: the parent view currently receiving this touch event

child

V: the child view associated with this Behavior

ev

MotionEvent: the MotionEvent describing the touch event being processed

Returns

boolean

true if this Behavior would like to intercept and take over the event stream.
The default always returns false.

onLayoutChild

Called when the parent CoordinatorLayout is about the lay out the given child view.

This method can be used to perform custom or modified layout of a child view
in place of the default child layout behavior. The Behavior's implementation can
delegate to the standard CoordinatorLayout measurement behavior by calling
parent.onLayoutChild.

onMeasureChild

Called when the parent CoordinatorLayout is about to measure the given child view.

This method can be used to perform custom or modified measurement of a child view
in place of the default child measurement behavior. The Behavior's implementation
can delegate to the standard CoordinatorLayout measurement behavior by calling
parent.onMeasureChild.

Parameters

parent

CoordinatorLayout: the parent CoordinatorLayout

child

V: the child to measure

parentWidthMeasureSpec

int: the width requirements for this view

widthUsed

int: extra space that has been used up by the parent
horizontally (possibly by other children of the parent)

parentHeightMeasureSpec

int: the height requirements for this view

heightUsed

int: extra space that has been used up by the parent
vertically (possibly by other children of the parent)

Returns

boolean

true if the Behavior measured the child view, false if the CoordinatorLayout
should perform its default measurement

onNestedFling is called when the current nested scrolling child view
detects the proper conditions for a fling. It reports if the child itself consumed
the fling. If it did not, the child is expected to show some sort of overscroll
indication. This method should return true if it consumes the fling, so that a child
that did not itself take an action in response can choose not to show an overfling
indication.

Parameters

coordinatorLayout

CoordinatorLayout: the CoordinatorLayout parent of the view this Behavior is
associated with

child

V: the child view of the CoordinatorLayout this Behavior is associated with

target

View: the descendant view of the CoordinatorLayout performing the nested scroll

onNestedPreFling is called when the current nested scrolling child view
detects the proper conditions for a fling, but it has not acted on it yet. A
Behavior can return true to indicate that it consumed the fling. If at least one
Behavior returns true, the fling should not be acted upon by the child.

Parameters

coordinatorLayout

CoordinatorLayout: the CoordinatorLayout parent of the view this Behavior is
associated with

child

V: the child view of the CoordinatorLayout this Behavior is associated with

target

View: the descendant view of the CoordinatorLayout performing the nested scroll

onNestedPreScroll is called each time the nested scroll is updated
by the nested scrolling child, before the nested scrolling child has consumed the scroll
distance itself. Each Behavior responding to the nested scroll will receive the
same values. The CoordinatorLayout will report as consumed the maximum number
of pixels in either direction that any Behavior responding to the nested scroll reported
as consumed.

Parameters

coordinatorLayout

CoordinatorLayout: the CoordinatorLayout parent of the view this Behavior is
associated with

child

V: the child view of the CoordinatorLayout this Behavior is associated with

target

View: the descendant view of the CoordinatorLayout performing the nested scroll

dx

int: the raw horizontal number of pixels that the user attempted to scroll

dy

int: the raw vertical number of pixels that the user attempted to scroll

consumed

int: out parameter. consumed[0] should be set to the distance of dx that
was consumed, consumed[1] should be set to the distance of dy that
was consumed

onNestedScroll is called each time the nested scroll is updated by the
nested scrolling child, with both consumed and unconsumed components of the scroll
supplied in pixels. Each Behavior responding to the nested scroll will receive the
same values.

Parameters

coordinatorLayout

CoordinatorLayout: the CoordinatorLayout parent of the view this Behavior is
associated with

child

V: the child view of the CoordinatorLayout this Behavior is associated with

target

View: the descendant view of the CoordinatorLayout performing the nested scroll

dxConsumed

int: horizontal pixels consumed by the target's own scrolling operation

dyConsumed

int: vertical pixels consumed by the target's own scrolling operation

dxUnconsumed

int: horizontal pixels not consumed by the target's own scrolling
operation, but requested by the user

dyUnconsumed

int: vertical pixels not consumed by the target's own scrolling operation,
but requested by the user

onRestoreInstanceState

Hook allowing a behavior to re-apply a representation of its internal state that had
previously been generated by onSaveInstanceState(CoordinatorLayout, V). This function will never
be called with a null state.

onSaveInstanceState

Hook allowing a behavior to generate a representation of its internal state
that can later be used to create a new instance with that same state.
This state should only contain information that is not persistent or can
not be reconstructed later.

Behavior state is only saved when both the parent CoordinatorLayout and
a view using this behavior have valid IDs set.

onStartNestedScroll

Called when a descendant of the CoordinatorLayout attempts to initiate a nested scroll.

Any Behavior associated with any direct child of the CoordinatorLayout may respond
to this event and return true to indicate that the CoordinatorLayout should act as
a nested scrolling parent for this scroll. Only Behaviors that return true from
this method will receive subsequent nested scroll events.

Parameters

coordinatorLayout

CoordinatorLayout: the CoordinatorLayout parent of the view this Behavior is
associated with

child

V: the child view of the CoordinatorLayout this Behavior is associated with

directTargetChild

View: the child view of the CoordinatorLayout that either is or
contains the target of the nested scroll operation

target

View: the descendant view of the CoordinatorLayout initiating the nested scroll

onTouchEvent

Respond to CoordinatorLayout touch events after this Behavior has started
intercepting them.

Behaviors may intercept touch events in order to help the CoordinatorLayout
manipulate its child views. For example, a Behavior may allow a user to drag a
UI pane open or closed. This method should perform actual mutations of view
layout state.

This method will be called regardless of the visibility of the associated child
of the behavior. If you only wish to handle touch events when the child is visible, you
should add a check to isShown() on the given child.

Parameters

parent

CoordinatorLayout: the parent view currently receiving this touch event

child

V: the child view associated with this Behavior

ev

MotionEvent: the MotionEvent describing the touch event being processed

Returns

boolean

true if this Behavior handled this touch event and would like to continue
receiving events in this stream. The default always returns false.