public static class AppBarLayout.ScrollingViewBehavior extends CoordinatorLayout.Behavior<V>
View
s which can scroll vertically and support
nested scrolling to automatically scroll any AppBarLayout
siblings.Constructor and Description |
---|
ScrollingViewBehavior() |
ScrollingViewBehavior(Context context,
AttributeSet attrs) |
Modifier and Type | Method and Description |
---|---|
int |
getLeftAndRightOffset() |
int |
getOverlayTop()
Returns the distance that this view should overlap any
AppBarLayout . |
int |
getTopAndBottomOffset() |
protected void |
layoutChild(CoordinatorLayout parent,
View child,
int layoutDirection) |
boolean |
layoutDependsOn(CoordinatorLayout parent,
View child,
View dependency)
Determine whether the supplied child view has another specific sibling view as a
layout dependency.
|
boolean |
onDependentViewChanged(CoordinatorLayout parent,
View child,
View dependency)
Respond to a change in a child's dependent view
This method is called whenever a dependent view changes in size or position outside
of the standard layout flow.
|
boolean |
onLayoutChild(CoordinatorLayout parent,
V child,
int layoutDirection)
Called when the parent CoordinatorLayout is about the lay out the given child view.
|
boolean |
onMeasureChild(CoordinatorLayout parent,
View child,
int parentWidthMeasureSpec,
int widthUsed,
int parentHeightMeasureSpec,
int heightUsed)
Called when the parent CoordinatorLayout is about to measure the given child view.
|
boolean |
onRequestChildRectangleOnScreen(CoordinatorLayout parent,
View child,
Rect rectangle,
boolean immediate)
Called when a child of the view associated with this behavior wants a particular
rectangle to be positioned onto the screen.
|
boolean |
setLeftAndRightOffset(int offset) |
void |
setOverlayTop(int overlayTop)
Set the distance that this view should overlap any
AppBarLayout . |
boolean |
setTopAndBottomOffset(int offset) |
blocksInteractionBelow, getInsetDodgeRect, getScrimColor, getScrimOpacity, getTag, isDirty, onApplyWindowInsets, onAttachedToLayoutParams, onDependentViewRemoved, onDetachedFromLayoutParams, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRestoreInstanceState, onSaveInstanceState, onStartNestedScroll, onStopNestedScroll, onTouchEvent, setTag
public ScrollingViewBehavior()
public ScrollingViewBehavior(Context context, AttributeSet attrs)
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency)
CoordinatorLayout.Behavior
This method will be called at least once in response to a layout request. If it returns true for a given child and dependency view pair, the parent CoordinatorLayout will:
CoordinatorLayout.Behavior.onDependentViewChanged(android.support.design.widget.CoordinatorLayout, V, android.view.View)
when the dependency view's layout or
position changes.layoutDependsOn
in class CoordinatorLayout.Behavior<View>
parent
- the parent view of the given childchild
- the child view to testdependency
- the proposed dependency of childCoordinatorLayout.Behavior.onDependentViewChanged(CoordinatorLayout, android.view.View, android.view.View)
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency)
CoordinatorLayout.Behavior
This method is called whenever a dependent view changes in size or position outside of the standard layout flow. A Behavior may use this method to appropriately update the child view in response.
A view's dependency is determined by
CoordinatorLayout.Behavior.layoutDependsOn(CoordinatorLayout, android.view.View, android.view.View)
or
if child
has set another view as it's anchor.
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.
onDependentViewChanged
in class CoordinatorLayout.Behavior<View>
parent
- the parent view of the given childchild
- the child view to manipulatedependency
- the dependent view that changedpublic boolean onRequestChildRectangleOnScreen(CoordinatorLayout parent, View child, Rect rectangle, boolean immediate)
CoordinatorLayout.Behavior
The contract for this method is the same as
ViewParent.requestChildRectangleOnScreen(View, Rect, boolean)
.
onRequestChildRectangleOnScreen
in class CoordinatorLayout.Behavior<View>
parent
- the CoordinatorLayout parent of the view this Behavior is
associated withchild
- the child view of the CoordinatorLayout this Behavior is
associated withrectangle
- The rectangle which the child wishes to be on the screen
in the child's coordinatesimmediate
- true to forbid animated or delayed scrolling, false otherwiseViewParent.requestChildRectangleOnScreen(View, Rect, boolean)
public boolean onMeasureChild(CoordinatorLayout parent, View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed)
CoordinatorLayout.Behavior
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
.
onMeasureChild
in class CoordinatorLayout.Behavior<View>
parent
- the parent CoordinatorLayoutchild
- the child to measureparentWidthMeasureSpec
- the width requirements for this viewwidthUsed
- extra space that has been used up by the parent
horizontally (possibly by other children of the parent)parentHeightMeasureSpec
- the height requirements for this viewheightUsed
- extra space that has been used up by the parent
vertically (possibly by other children of the parent)protected void layoutChild(CoordinatorLayout parent, View child, int layoutDirection)
public final void setOverlayTop(int overlayTop)
AppBarLayout
.overlayTop
- the distance in pxpublic final int getOverlayTop()
AppBarLayout
.public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection)
CoordinatorLayout.Behavior
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
.
If a Behavior implements
CoordinatorLayout.Behavior.onDependentViewChanged(CoordinatorLayout, android.view.View, android.view.View)
to change the position of a view in response to a dependent view changing, it
should also implement onLayoutChild
in such a way that respects those
dependent views. onLayoutChild
will always be called for a dependent view
after its dependency has been laid out.
onLayoutChild
in class CoordinatorLayout.Behavior<V extends View>
parent
- the parent CoordinatorLayoutchild
- child view to lay outlayoutDirection
- the resolved layout direction for the CoordinatorLayout, such as
ViewCompat.LAYOUT_DIRECTION_LTR
or
ViewCompat.LAYOUT_DIRECTION_RTL
.public boolean setTopAndBottomOffset(int offset)
public boolean setLeftAndRightOffset(int offset)
public int getTopAndBottomOffset()
public int getLeftAndRightOffset()