AppBarLayout.ScrollingViewBehavior
public static class AppBarLayout.ScrollingViewBehavior
extends Behavior<View>
行为应该由 View
使用,它可以垂直滚动并支持嵌套滚动以自动滚动任何 AppBarLayout
兄弟姐妹。
Summary
Public methods |
int |
getLeftAndRightOffset() |
final int |
getOverlayTop() 返回此视图应与任何 AppBarLayout 重叠的距离。 |
int |
getTopAndBottomOffset() |
boolean |
layoutDependsOn(CoordinatorLayout parent, View child, View dependency) 确定提供的子视图是否具有另一个特定的兄弟视图作为布局依赖关系。 |
boolean |
onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) 回应孩子的独立观点的变化 只要依赖视图在标准布局流程之外的大小或位置发生变化,就会调用此方法。 |
boolean |
onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) 当父母CoordinatorLayout关于布置给定子视图时调用。 |
boolean |
onMeasureChild(CoordinatorLayout parent, View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) 父母CoordinatorLayout即将测量给定子视图时调用。 |
boolean |
setLeftAndRightOffset(int offset) |
final void |
setOverlayTop(int overlayTop) 设置此视图应与任何 AppBarLayout 重叠的距离。 |
boolean |
setTopAndBottomOffset(int offset) |
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 ()
返回此视图应与任何 AppBarLayout
重叠的距离。
getTopAndBottomOffset
int getTopAndBottomOffset ()
layoutDependsOn
boolean layoutDependsOn (CoordinatorLayout parent,
View child,
View dependency)
确定提供的子视图是否具有另一个特定的兄弟视图作为布局依赖关系。
这个方法将被调用至少一次以响应布局请求。 如果它对给定的子对象和依赖性视图对返回true,那么父级CoordinatorLayout将:
- 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 |
onMeasureChild
boolean onMeasureChild (CoordinatorLayout parent,
View child,
int parentWidthMeasureSpec,
int widthUsed,
int parentHeightMeasureSpec,
int heightUsed)
父母CoordinatorLayout即将测量给定子视图时调用。
此方法可用于执行自定义或修改的子视图测量,以代替默认的子测量行为。 行为的实现可以通过调用parent.onMeasureChild
委托给标准CoordinatorLayout测量行为。
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)
设置此视图应与任何 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
|