public static class FloatingActionButton.Behavior extends CoordinatorLayout.Behavior<FloatingActionButton>
FloatingActionButton
instances. Its main function
is to move FloatingActionButton
views so that any displayed Snackbar
s do
not cover them.Constructor and Description |
---|
Behavior() |
Behavior(Context context,
AttributeSet attrs) |
Modifier and Type | Method and Description |
---|---|
boolean |
getInsetDodgeRect(CoordinatorLayout parent,
FloatingActionButton child,
Rect rect)
Called when a view is set to dodge view insets.
|
boolean |
isAutoHideEnabled()
Returns whether the associated FloatingActionButton automatically hides when there is
not enough space to be displayed.
|
void |
onAttachedToLayoutParams(CoordinatorLayout.LayoutParams lp)
Called when the Behavior has been attached to a LayoutParams instance.
|
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.
|
boolean |
onLayoutChild(CoordinatorLayout parent,
FloatingActionButton child,
int layoutDirection)
Called when the parent CoordinatorLayout is about the lay out the given child view.
|
void |
setAutoHideEnabled(boolean autoHide)
Sets whether the associated FloatingActionButton automatically hides when there is
not enough space to be displayed.
|
blocksInteractionBelow, getScrimColor, getScrimOpacity, getTag, isDirty, layoutDependsOn, onApplyWindowInsets, onDependentViewRemoved, onDetachedFromLayoutParams, onInterceptTouchEvent, onMeasureChild, onNestedFling, onNestedPreFling, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestChildRectangleOnScreen, onRestoreInstanceState, onSaveInstanceState, onStartNestedScroll, onStopNestedScroll, onTouchEvent, setTag
public Behavior()
public Behavior(Context context, AttributeSet attrs)
public void setAutoHideEnabled(boolean autoHide)
AppBarLayout
and BottomSheetBehavior
.autoHide
- true to enable automatic hidingpublic boolean isAutoHideEnabled()
public void onAttachedToLayoutParams(@NonNull CoordinatorLayout.LayoutParams lp)
CoordinatorLayout.Behavior
This will be called after the LayoutParams has been instantiated and can be modified.
onAttachedToLayoutParams
in class CoordinatorLayout.Behavior<FloatingActionButton>
lp
- the LayoutParams instance that this Behavior has been attached topublic boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency)
CoordinatorLayout.Behavior
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
CoordinatorLayout.Behavior.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.
onDependentViewChanged
in class CoordinatorLayout.Behavior<FloatingActionButton>
parent
- the parent view of the given childchild
- the child view to manipulatedependency
- the dependent view that changedpublic boolean onLayoutChild(CoordinatorLayout parent, FloatingActionButton child, int layoutDirection)
CoordinatorLayout.Behavior
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
CoordinatorLayout.Behavior.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.
onLayoutChild
in class CoordinatorLayout.Behavior<FloatingActionButton>
parent
- the parent CoordinatorLayoutchild
- child view to lay outlayoutDirection
- the resolved layout direction for the CoordinatorLayout, such as
ViewCompat.LAYOUT_DIRECTION_LTR
or
ViewCompat.LAYOUT_DIRECTION_RTL
.public boolean getInsetDodgeRect(@NonNull CoordinatorLayout parent, @NonNull FloatingActionButton child, @NonNull Rect rect)
CoordinatorLayout.Behavior
This method allows a behavior to update the rectangle that should be dodged.
The rectangle should be in the parent's coordinate system and within the child's
bounds. If not, a IllegalArgumentException
is thrown.
getInsetDodgeRect
in class CoordinatorLayout.Behavior<FloatingActionButton>
parent
- the CoordinatorLayout parent of the view this Behavior is
associated withchild
- the child view of the CoordinatorLayout this Behavior is associated withrect
- the rect to update with the dodge rectangle