public static class FloatingActionButton.Behavior
extends Behavior<FloatingActionButton>
| java.lang.Object | ||
| android.support.design.widget.CoordinatorLayout.Behavior<android.support.design.widget.FloatingActionButton> | ||
| android.support.design.widget.FloatingActionButton.Behavior | ||
设计用于FloatingActionButton实例的行为。 它的主要功能是移动FloatingActionButton视图,以便任何显示的Snackbar都不会覆盖它们。
Public constructors |
|
|---|---|
FloatingActionButton.Behavior() |
|
FloatingActionButton.Behavior(Context context, AttributeSet attrs) |
|
公共方法(Public methods) |
|
|---|---|
boolean |
layoutDependsOn(CoordinatorLayout parent, FloatingActionButton child, View dependency) 确定提供的子视图是否具有另一个特定的兄弟视图作为布局依赖关系。 |
boolean |
onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) 回应孩子的独立观点的变化 只要依赖视图在标准布局流程之外的大小或位置发生变化,就会调用此方法。 |
void |
onDependentViewRemoved(CoordinatorLayout parent, FloatingActionButton child, View dependency) 回应孩子的独立观点被删除。 |
boolean |
onLayoutChild(CoordinatorLayout parent, FloatingActionButton child, int layoutDirection) 当父母CoordinatorLayout关于布置给定子视图时调用。 |
继承方法(Inherited methods) |
|
|---|---|
android.support.design.widget.CoordinatorLayout.Behavior
|
|
java.lang.Object
|
|
FloatingActionButton.Behavior ()
FloatingActionButton.Behavior (Context context, AttributeSet attrs)
| 参数(Parameters) | |
|---|---|
context |
Context
|
attrs |
AttributeSet
|
boolean layoutDependsOn (CoordinatorLayout parent, FloatingActionButton child, View dependency)
确定提供的子视图是否具有另一个特定的兄弟视图作为布局依赖关系。
这个方法将被调用至少一次以响应布局请求。 如果它对给定的子对象和依赖性视图对返回true,那么父级CoordinatorLayout将:
onDependentViewChanged(CoordinatorLayout, V, View) when the dependency view's layout or position changes.| 参数(Parameters) | |
|---|---|
parent |
CoordinatorLayout: the parent view of the given child |
child |
FloatingActionButton: 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 |
boolean onDependentViewChanged (CoordinatorLayout parent, FloatingActionButton 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 |
FloatingActionButton: 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 |
void onDependentViewRemoved (CoordinatorLayout parent, FloatingActionButton child, View dependency)
回应孩子的独立观点被删除。
在从父视图中删除相关视图后调用此方法。 行为可以使用此方法来适当地更新子视图作为响应。
视图的依赖关系由 layoutDependsOn(CoordinatorLayout, android.view.View, android.view.View)决定,或者 child设置了另一个视图,因为它是锚点。
| 参数(Parameters) | |
|---|---|
parent |
CoordinatorLayout: the parent view of the given child |
child |
FloatingActionButton: the child view to manipulate |
dependency |
View: the dependent view that has been removed |
boolean onLayoutChild (CoordinatorLayout parent, FloatingActionButton child, int layoutDirection)
当父母CoordinatorLayout关于布置给定子视图时调用。
此方法可用于执行子视图的自定义或修改布局,以取代默认子布局行为。 行为的实现可以通过调用parent.onLayoutChild委托给标准的CoordinatorLayout测量行为。
如果行为实现onDependentViewChanged(CoordinatorLayout, android.view.View, android.view.View)以响应相关视图更改而更改视图的位置,则还应该以尊重这些相关视图的方式实现onLayoutChild 。 onLayoutChild 在其依赖关系被布置后,将始终被称为依赖视图。
| 参数(Parameters) | |
|---|---|
parent |
CoordinatorLayout: the parent CoordinatorLayout |
child |
FloatingActionButton: 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 |