HideBottomViewOnScrollBehavior

public class HideBottomViewOnScrollBehavior
extends Behavior<V extends View>

java.lang.Object
   ↳ androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior<V extends android.view.View>
     ↳ com.google.android.material.behavior.HideBottomViewOnScrollBehavior<V extends android.view.View>
BottomAppBar.Behavior Behavior designed for use with BottomAppBar instances. 


The CoordinatorLayout.Behavior for a View within a CoordinatorLayout to hide the view off the bottom of the screen when scrolling down, and show it when scrolling up.

Summary

Nested classes

interface HideBottomViewOnScrollBehavior.OnScrollStateChangedListener

Interface definition for a listener to be notified when the bottom view scroll state changes. 

Constants

int STATE_SCROLLED_DOWN

State of the bottom view when it's scrolled down.

int STATE_SCROLLED_UP

State of the bottom view when it's scrolled up.

Public constructors

HideBottomViewOnScrollBehavior()
HideBottomViewOnScrollBehavior(Context context, AttributeSet attrs)

Public methods

void addOnScrollStateChangedListener(HideBottomViewOnScrollBehavior.OnScrollStateChangedListener listener)

Adds a listener to be notified of bottom view scroll state changes.

void clearOnScrollStateChangedListeners()

Remove all previously added HideBottomViewOnScrollBehavior.OnScrollStateChangedListeners.

boolean isScrolledDown()

Returns true if the current state is scrolled down.

boolean isScrolledUp()

Returns true if the current state is scrolled up.

boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection)
void onNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, int[] consumed)
boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes, int type)
void removeOnScrollStateChangedListener(HideBottomViewOnScrollBehavior.OnScrollStateChangedListener listener)

Removes a previously added listener.

void setAdditionalHiddenOffsetY(V child, int offset)

Sets an additional offset for the y position used to hide the view.

void slideDown(V child)

Performs an animation that will slide the child from it's current position to be totally off the screen.

void slideDown(V child, boolean animate)

Slides the child with or without animation from its current position to be totally off the screen.

void slideUp(V child)

Performs an animation that will slide the child from it's current position to be totally on the screen.

void slideUp(V child, boolean animate)

Slides the child with or without animation from its current position to be totally on the screen.

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()

Constants

STATE_SCROLLED_DOWN

public static final int STATE_SCROLLED_DOWN

State of the bottom view when it's scrolled down.

Constant Value: 1 (0x00000001)

STATE_SCROLLED_UP

public static final int STATE_SCROLLED_UP

State of the bottom view when it's scrolled up.

Constant Value: 2 (0x00000002)

Public constructors

HideBottomViewOnScrollBehavior

public HideBottomViewOnScrollBehavior ()

HideBottomViewOnScrollBehavior

public HideBottomViewOnScrollBehavior (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Public methods

addOnScrollStateChangedListener

public void addOnScrollStateChangedListener (HideBottomViewOnScrollBehavior.OnScrollStateChangedListener listener)

Adds a listener to be notified of bottom view scroll state changes.

Parameters
listener HideBottomViewOnScrollBehavior.OnScrollStateChangedListener: The listener to notify when bottom view scroll state changes.

clearOnScrollStateChangedListeners

public void clearOnScrollStateChangedListeners ()

Remove all previously added HideBottomViewOnScrollBehavior.OnScrollStateChangedListeners.

isScrolledDown

public boolean isScrolledDown ()

Returns true if the current state is scrolled down.

Returns
boolean

isScrolledUp

public boolean isScrolledUp ()

Returns true if the current state is scrolled up.

Returns
boolean

onLayoutChild

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

Parameters
parent CoordinatorLayout

child V

layoutDirection int

Returns
boolean

onNestedScroll

public void onNestedScroll (CoordinatorLayout coordinatorLayout, 
                V child, 
                View target, 
                int dxConsumed, 
                int dyConsumed, 
                int dxUnconsumed, 
                int dyUnconsumed, 
                int type, 
                int[] consumed)

Parameters
coordinatorLayout CoordinatorLayout

child V

target View

dxConsumed int

dyConsumed int

dxUnconsumed int

dyUnconsumed int

type int

consumed int

onStartNestedScroll

public boolean onStartNestedScroll (CoordinatorLayout coordinatorLayout, 
                V child, 
                View directTargetChild, 
                View target, 
                int nestedScrollAxes, 
                int type)

Parameters
coordinatorLayout CoordinatorLayout

child V

directTargetChild View

target View

nestedScrollAxes int

type int

Returns
boolean

removeOnScrollStateChangedListener

public void removeOnScrollStateChangedListener (HideBottomViewOnScrollBehavior.OnScrollStateChangedListener listener)

Removes a previously added listener.

Parameters
listener HideBottomViewOnScrollBehavior.OnScrollStateChangedListener: The listener to remove.

setAdditionalHiddenOffsetY

public void setAdditionalHiddenOffsetY (V child, 
                int offset)

Sets an additional offset for the y position used to hide the view.

Parameters
child V: the child view that is hidden by this behavior

offset int: the additional offset in pixels that should be added when the view slides away

slideDown

public void slideDown (V child)

Performs an animation that will slide the child from it's current position to be totally off the screen.

Parameters
child V

slideDown

public void slideDown (V child, 
                boolean animate)

Slides the child with or without animation from its current position to be totally off the screen.

Parameters
child V

animate boolean: true to slide with animation.

slideUp

public void slideUp (V child)

Performs an animation that will slide the child from it's current position to be totally on the screen.

Parameters
child V

slideUp

public void slideUp (V child, 
                boolean animate)

Slides the child with or without animation from its current position to be totally on the screen.

Parameters
child V

animate boolean: true to slide with animation.