AppBarLayout.ScrollingViewBehavior
public
static
class
AppBarLayout.ScrollingViewBehavior
extends Behavior<View>
Behavior which should be used by View
s which can scroll vertically and support
nested scrolling to automatically scroll any AppBarLayout
siblings.
Summary
Public methods |
int
|
getLeftAndRightOffset()
|
final
int
|
getOverlayTop()
Returns the distance that this view should overlap any AppBarLayout .
|
int
|
getTopAndBottomOffset()
|
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
|
setLeftAndRightOffset(int offset)
|
final
void
|
setOverlayTop(int overlayTop)
Set the distance that this view should overlap any AppBarLayout .
|
boolean
|
setTopAndBottomOffset(int offset)
|
Inherited methods |
From
class
android.support.design.widget.CoordinatorLayout.Behavior
|
From
class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long millis, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long millis)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
|
Public constructors
AppBarLayout.ScrollingViewBehavior
AppBarLayout.ScrollingViewBehavior ()
AppBarLayout.ScrollingViewBehavior
AppBarLayout.ScrollingViewBehavior (Context context,
AttributeSet attrs)
Parameters |
context |
Context
|
attrs |
AttributeSet
|
Public methods
getLeftAndRightOffset
int getLeftAndRightOffset ()
getOverlayTop
int getOverlayTop ()
Returns the distance that this view should overlap any AppBarLayout
.
getTopAndBottomOffset
int getTopAndBottomOffset ()
layoutDependsOn
boolean layoutDependsOn (CoordinatorLayout parent,
View child,
View dependency)
Determine whether the supplied child view has another specific sibling view as a
layout dependency.
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:
- Always lay out this child after the dependent child is laid out, regardless
of child order.
- Call
onDependentViewChanged(CoordinatorLayout, V, View)
when the dependency view's layout or
position changes.
Parameters |
parent |
CoordinatorLayout :
the parent view of the given child |
child |
View :
the child view to test |
dependency |
View :
the proposed dependency of child |
Returns |
boolean |
true if child's layout depends on the proposed dependency's layout,
false otherwise |
onDependentViewChanged
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. A Behavior may use this method to appropriately update
the child view in response.
A view's dependency is determined by
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.
Parameters |
parent |
CoordinatorLayout :
the parent view of the given child |
child |
View :
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
|
onLayoutChild
boolean onLayoutChild (CoordinatorLayout parent,
V child,
int layoutDirection)
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
.
If a Behavior implements
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.
Parameters |
parent |
CoordinatorLayout :
the parent CoordinatorLayout |
child |
V :
child view to lay out |
layoutDirection |
int :
the resolved layout direction for the CoordinatorLayout, such as
LAYOUT_DIRECTION_LTR or
LAYOUT_DIRECTION_RTL . |
Returns |
boolean |
true if the Behavior performed layout of the child view, false to request
default layout behavior
|
onMeasureChild
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.
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 |
View :
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
|
setLeftAndRightOffset
boolean setLeftAndRightOffset (int offset)
setOverlayTop
void setOverlayTop (int overlayTop)
Set the distance that this view should overlap any AppBarLayout
.
Parameters |
overlayTop |
int :
the distance in px
|
setTopAndBottomOffset
boolean setTopAndBottomOffset (int offset)
Protected methods
layoutChild
void layoutChild (CoordinatorLayout parent,
View child,
int layoutDirection)
Parameters |
parent |
CoordinatorLayout
|
child |
View
|
layoutDirection |
int
|
layoutChild
void layoutChild (CoordinatorLayout parent,
V child,
int layoutDirection)
Parameters |
parent |
CoordinatorLayout
|
child |
V
|
layoutDirection |
int
|