AppBarLayout.ScrollingViewBehavior

public static class AppBarLayout.ScrollingViewBehavior
extends Behavior<V extends View>

java.lang.Object
   ↳ androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior<V extends android.view.View>
     ↳ com.google.android.material.appbar.AppBarLayout.ScrollingViewBehavior
SearchBar.ScrollingViewBehavior Behavior that sets up the scroll-away mode for an SearchBar


Behavior which should be used by Views which can scroll vertically and support nested scrolling to automatically scroll any AppBarLayout siblings.

Summary

Public constructors

ScrollingViewBehavior()
ScrollingViewBehavior(Context context, AttributeSet attrs)

Public methods

int getLeftAndRightOffset()
final int getOverlayTop()

Returns the distance that this view should overlap any AppBarLayout.

int getTopAndBottomOffset()
boolean isHorizontalOffsetEnabled()
boolean isVerticalOffsetEnabled()
boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency)
boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency)
void onDependentViewRemoved(CoordinatorLayout parent, View child, View dependency)
boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection)
boolean onMeasureChild(CoordinatorLayout parent, View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed)
boolean onRequestChildRectangleOnScreen(CoordinatorLayout parent, View child, Rect rectangle, boolean immediate)
void setHorizontalOffsetEnabled(boolean horizontalOffsetEnabled)
boolean setLeftAndRightOffset(int offset)
final void setOverlayTop(int overlayTop)

Set the distance that this view should overlap any AppBarLayout.

boolean setTopAndBottomOffset(int offset)
void setVerticalOffsetEnabled(boolean verticalOffsetEnabled)

Protected methods

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

Inherited methods

boolean blocksInteractionBelow(CoordinatorLayout arg0, V arg1)
boolean getInsetDodgeRect(CoordinatorLayout arg0, V arg1, Rect arg2)
int getScrimColor(CoordinatorLayout arg0, V arg1)
float getScrimOpacity(CoordinatorLayout arg0, V arg1)
static Object getTag(View arg0)
boolean layoutDependsOn(CoordinatorLayout arg0, V arg1, View arg2)
WindowInsetsCompat onApplyWindowInsets(CoordinatorLayout arg0, V arg1, WindowInsetsCompat arg2)
void onAttachedToLayoutParams(CoordinatorLayout.LayoutParams arg0)
boolean onDependentViewChanged(CoordinatorLayout arg0, V arg1, View arg2)
void onDependentViewRemoved(CoordinatorLayout arg0, V arg1, View arg2)
void onDetachedFromLayoutParams()
boolean onInterceptTouchEvent(CoordinatorLayout arg0, V arg1, MotionEvent arg2)
boolean onLayoutChild(CoordinatorLayout arg0, V arg1, int arg2)
boolean onMeasureChild(CoordinatorLayout arg0, V arg1, int arg2, int arg3, int arg4, int arg5)
boolean onNestedFling(CoordinatorLayout arg0, V arg1, View arg2, float arg3, float arg4, boolean arg5)
boolean onNestedPreFling(CoordinatorLayout arg0, V arg1, View arg2, float arg3, float arg4)
void onNestedPreScroll(CoordinatorLayout arg0, V arg1, View arg2, int arg3, int arg4, int[] arg5, int arg6)
void onNestedPreScroll(CoordinatorLayout arg0, V arg1, View arg2, int arg3, int arg4, int[] arg5)
void onNestedScroll(CoordinatorLayout arg0, V arg1, View arg2, int arg3, int arg4, int arg5, int arg6, int arg7)
void onNestedScroll(CoordinatorLayout arg0, V arg1, View arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int[] arg8)
void onNestedScroll(CoordinatorLayout arg0, V arg1, View arg2, int arg3, int arg4, int arg5, int arg6)
void onNestedScrollAccepted(CoordinatorLayout arg0, V arg1, View arg2, View arg3, int arg4, int arg5)
void onNestedScrollAccepted(CoordinatorLayout arg0, V arg1, View arg2, View arg3, int arg4)
boolean onRequestChildRectangleOnScreen(CoordinatorLayout arg0, V arg1, Rect arg2, boolean arg3)
void onRestoreInstanceState(CoordinatorLayout arg0, V arg1, Parcelable arg2)
Parcelable onSaveInstanceState(CoordinatorLayout arg0, V arg1)
boolean onStartNestedScroll(CoordinatorLayout arg0, V arg1, View arg2, View arg3, int arg4, int arg5)
boolean onStartNestedScroll(CoordinatorLayout arg0, V arg1, View arg2, View arg3, int arg4)
void onStopNestedScroll(CoordinatorLayout arg0, V arg1, View arg2, int arg3)
void onStopNestedScroll(CoordinatorLayout arg0, V arg1, View arg2)
boolean onTouchEvent(CoordinatorLayout arg0, V arg1, MotionEvent arg2)
static void setTag(View arg0, Object arg1)
Object clone()
boolean equals(Object arg0)
void finalize()
final Class<?> getClass()
int hashCode()
final void notify()
final void notifyAll()
String toString()
final void wait(long arg0, int arg1)
final void wait(long arg0)
final void wait()

Public constructors

ScrollingViewBehavior

public ScrollingViewBehavior ()

ScrollingViewBehavior

public ScrollingViewBehavior (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Public methods

getLeftAndRightOffset

public int getLeftAndRightOffset ()

Returns
int

getOverlayTop

public final int getOverlayTop ()

Returns the distance that this view should overlap any AppBarLayout.

Returns
int

getTopAndBottomOffset

public int getTopAndBottomOffset ()

Returns
int

isHorizontalOffsetEnabled

public boolean isHorizontalOffsetEnabled ()

Returns
boolean

isVerticalOffsetEnabled

public boolean isVerticalOffsetEnabled ()

Returns
boolean

layoutDependsOn

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

Parameters
parent CoordinatorLayout

child View

dependency View

Returns
boolean

onDependentViewChanged

public boolean onDependentViewChanged (CoordinatorLayout parent, 
                View child, 
                View dependency)

Parameters
parent CoordinatorLayout

child View

dependency View

Returns
boolean

onDependentViewRemoved

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

Parameters
parent CoordinatorLayout

child View

dependency View

onLayoutChild

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

Parameters
parent CoordinatorLayout

child V

layoutDirection int

Returns
boolean

onMeasureChild

public boolean onMeasureChild (CoordinatorLayout parent, 
                View child, 
                int parentWidthMeasureSpec, 
                int widthUsed, 
                int parentHeightMeasureSpec, 
                int heightUsed)

Parameters
parent CoordinatorLayout

child View

parentWidthMeasureSpec int

widthUsed int

parentHeightMeasureSpec int

heightUsed int

Returns
boolean

onRequestChildRectangleOnScreen

public boolean onRequestChildRectangleOnScreen (CoordinatorLayout parent, 
                View child, 
                Rect rectangle, 
                boolean immediate)

Parameters
parent CoordinatorLayout

child View

rectangle Rect

immediate boolean

Returns
boolean

setHorizontalOffsetEnabled

public void setHorizontalOffsetEnabled (boolean horizontalOffsetEnabled)

Parameters
horizontalOffsetEnabled boolean

setLeftAndRightOffset

public boolean setLeftAndRightOffset (int offset)

Parameters
offset int

Returns
boolean

setOverlayTop

public final void setOverlayTop (int overlayTop)

Set the distance that this view should overlap any AppBarLayout.

Parameters
overlayTop int: the distance in px

setTopAndBottomOffset

public boolean setTopAndBottomOffset (int offset)

Parameters
offset int

Returns
boolean

setVerticalOffsetEnabled

public void setVerticalOffsetEnabled (boolean verticalOffsetEnabled)

Parameters
verticalOffsetEnabled boolean

Protected methods

layoutChild

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

Parameters
parent CoordinatorLayout

child V

layoutDirection int

layoutChild

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

Parameters
parent CoordinatorLayout

child View

layoutDirection int

shouldHeaderOverlapScrollingChild

protected boolean shouldHeaderOverlapScrollingChild ()

Returns
boolean