Most visited

Recently visited

AppBarLayout.ScrollingViewBehavior

public static class AppBarLayout.ScrollingViewBehavior
extends Behavior<View>

java.lang.Object
   ↳ android.support.design.widget.CoordinatorLayout.Behavior<android.view.View>
     ↳ android.support.design.widget.AppBarLayout.ScrollingViewBehavior


行为应该由 View使用,它可以垂直滚动并支持嵌套滚动以自动滚动任何 AppBarLayout兄弟姐妹。

Summary

Public constructors

AppBarLayout.ScrollingViewBehavior()
AppBarLayout.ScrollingViewBehavior(Context context, AttributeSet attrs)

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)

Protected methods

void layoutChild(CoordinatorLayout parent, View child, int layoutDirection)
void layoutChild(CoordinatorLayout parent, V child, int layoutDirection)

Inherited methods

From class android.support.design.widget.CoordinatorLayout.Behavior
From class java.lang.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 ()

Returns
int

getOverlayTop

int getOverlayTop ()

返回此视图应与任何 AppBarLayout重叠的距离。

Returns
int

getTopAndBottomOffset

int getTopAndBottomOffset ()

Returns
int

layoutDependsOn

boolean layoutDependsOn (CoordinatorLayout parent, 
                View child, 
                View dependency)

确定提供的子视图是否具有另一个特定的兄弟视图作为布局依赖关系。

这个方法将被调用至少一次以响应布局请求。 如果它对给定的子对象和依赖性视图对返回true,那么父级CoordinatorLayout将:

  1. Always lay out this child after the dependent child is laid out, regardless of child order.
  2. 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)

回应孩子的独立观点的变化

只要依赖视图在标准布局流程之外的大小或位置发生变化,就会调用此方法。 行为可以使用此方法来适当地更新子视图作为响应。

视图的依赖关系由 layoutDependsOn(CoordinatorLayout, android.view.View, android.view.View)决定,或者如果 child已将另一个视图设置为锚点,则视图的依赖关系由 layoutDependsOn(CoordinatorLayout, android.view.View, android.view.View)决定。

请注意,如果行为通过此方法更改了孩子的布局,它也应该能够重建onLayoutChild的正确位置。 onDependentViewChanged在正常布局期间不会被调用,因为每个子视图的布局总是以依赖性顺序发生。

如果行为更改了子视图的大小或位置,则它应该返回true。 默认实现返回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)

当父母CoordinatorLayout关于布置给定子视图时调用。

此方法可用于执行子视图的自定义或修改布局,以取代默认子布局行为。 行为的实现可以通过调用parent.onLayoutChild委托给标准CoordinatorLayout测量行为。

如果行为实现onDependentViewChanged(CoordinatorLayout, android.view.View, android.view.View)以响应相关视图更改而更改视图的位置,则还应该以尊重这些相关视图的方式实现onLayoutChild onLayoutChild依赖关系后,将始终调用onLayoutChild依赖视图。

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)

父母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)

Parameters
offset int
Returns
boolean

setOverlayTop

void setOverlayTop (int overlayTop)

设置此视图应与任何 AppBarLayout重叠的距离。

Parameters
overlayTop int: the distance in px

setTopAndBottomOffset

boolean setTopAndBottomOffset (int offset)

Parameters
offset int
Returns
boolean

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

Hooray!