AppBarLayout.Behavior

public class AppBarLayout.Behavior extends AppBarLayout.BaseBehavior


The default Behavior for AppBarLayout. Implements the necessary nested scroll handling with offsetting.

Summary

Nested types

Callback to allow control over any AppBarLayout dragging.

Public constructors

Behavior(Context context, AttributeSet attrs)

Public methods

int
int
boolean
boolean
boolean
onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent ev)
boolean
onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection)
boolean
onTouchEvent(CoordinatorLayout parent, V child, MotionEvent ev)
void
setHorizontalOffsetEnabled(boolean horizontalOffsetEnabled)
boolean
boolean
void
setVerticalOffsetEnabled(boolean verticalOffsetEnabled)

Protected methods

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

Inherited methods

From com.google.android.material.appbar.AppBarLayout.BaseBehavior
boolean
onLayoutChild(CoordinatorLayout parent, T abl, int layoutDirection)
boolean
onMeasureChild(
    CoordinatorLayout parent,
    T child,
    int parentWidthMeasureSpec,
    int widthUsed,
    int parentHeightMeasureSpec,
    int heightUsed
)
void
onNestedPreScroll(
    CoordinatorLayout coordinatorLayout,
    T child,
    View target,
    int dx,
    int dy,
    int[] consumed,
    int type
)
void
onNestedScroll(
    CoordinatorLayout coordinatorLayout,
    T child,
    View target,
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    int type,
    int[] consumed
)
void
onRestoreInstanceState(
    CoordinatorLayout parent,
    T appBarLayout,
    Parcelable state
)
Parcelable
onSaveInstanceState(CoordinatorLayout parent, T abl)
boolean
onStartNestedScroll(
    CoordinatorLayout parent,
    T child,
    View directTargetChild,
    View target,
    int nestedScrollAxes,
    int type
)
void
onStopNestedScroll(
    CoordinatorLayout coordinatorLayout,
    T abl,
    View target,
    int type
)
void

Set a callback to control any AppBarLayout dragging.

Public constructors

Behavior

public Behavior()

Behavior

public Behavior(Context context, AttributeSet attrs)

Public methods

getLeftAndRightOffset

public int getLeftAndRightOffset()

getTopAndBottomOffset

public int getTopAndBottomOffset()

isHorizontalOffsetEnabled

public boolean isHorizontalOffsetEnabled()

isVerticalOffsetEnabled

public boolean isVerticalOffsetEnabled()

onInterceptTouchEvent

public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent ev)

onLayoutChild

public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection)

onTouchEvent

public boolean onTouchEvent(CoordinatorLayout parent, V child, MotionEvent ev)

setHorizontalOffsetEnabled

public void setHorizontalOffsetEnabled(boolean horizontalOffsetEnabled)

setLeftAndRightOffset

public boolean setLeftAndRightOffset(int offset)

setTopAndBottomOffset

public boolean setTopAndBottomOffset(int offset)

setVerticalOffsetEnabled

public void setVerticalOffsetEnabled(boolean verticalOffsetEnabled)

Protected methods

layoutChild

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