Android APIs
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

Class Overview

Behavior designed for use with FloatingActionButton instances. It's main function is to move FloatingActionButton views so that any displayed Snackbars do not cover them.

Summary

Public Constructors
FloatingActionButton.Behavior()
Public Methods
boolean layoutDependsOn(CoordinatorLayout parent, FloatingActionButton child, View dependency)
Determine whether the supplied child view has another specific sibling view as a layout dependency.
boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton 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.

void onDependentViewRemoved(CoordinatorLayout parent, FloatingActionButton child, View dependency)
Respond to a child's dependent view being removed.
boolean onLayoutChild(CoordinatorLayout parent, FloatingActionButton child, int layoutDirection)
Called when the parent CoordinatorLayout is about the lay out the given child view.
[Expand]
Inherited Methods
From class android.support.design.widget.CoordinatorLayout.Behavior
From class java.lang.Object

Public Constructors

public FloatingActionButton.Behavior ()

Public Methods

public boolean layoutDependsOn (CoordinatorLayout parent, FloatingActionButton 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:

  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 the parent view of the given child
child the child view to test
dependency the proposed dependency of child
Returns
  • true if child's layout depends on the proposed dependency's layout, false otherwise

public boolean onDependentViewChanged (CoordinatorLayout parent, FloatingActionButton 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 the parent view of the given child
child the child view to manipulate
dependency the dependent view that changed
Returns
  • true if the Behavior changed the child view's size or position, false otherwise

public void onDependentViewRemoved (CoordinatorLayout parent, FloatingActionButton child, View dependency)

Respond to a child's dependent view being removed.

This method is called after a dependent view has been removed from the parent. 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.

Parameters
parent the parent view of the given child
child the child view to manipulate
dependency the dependent view that has been removed

public boolean onLayoutChild (CoordinatorLayout parent, FloatingActionButton 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.onMeasureChild.

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 the parent CoordinatorLayout
child child view to lay out
layoutDirection the resolved layout direction for the CoordinatorLayout, such as LAYOUT_DIRECTION_LTR or LAYOUT_DIRECTION_RTL.
Returns
  • true if the Behavior performed layout of the child view, false to request default layout behavior