# AppBarLayout.ScrollingViewBehavior

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/appbar/AppBarLayout.java)

*** ** * ** ***


```
public class AppBarLayout.ScrollingViewBehavior
```

<br />

Known direct subclasses [SearchBar.ScrollingViewBehavior](https://developer.android.com/reference/com/google/android/material/search/SearchBar.ScrollingViewBehavior)

|---|---|
| `https://developer.android.com/reference/com/google/android/material/search/SearchBar.ScrollingViewBehavior` | Behavior that sets up the scroll-away mode for an `https://developer.android.com/reference/com/google/android/material/search/SearchBar`. |

*** ** * ** ***

Behavior which should be used by Views which can scroll vertically and support nested scrolling to automatically scroll any `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` siblings.

## Summary

| ### Public fields |
|---|---|
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#overlayTop()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#ScrollingViewBehavior()()` |
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#ScrollingViewBehavior(Context,AttributeSet)(Context context, AttributeSet attrs)` |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#getLeftAndRightOffset()()` |
| `final int` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#getOverlayTop()()` Returns the distance that this view should overlap any `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`. |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#getTopAndBottomOffset()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#isHorizontalOffsetEnabled()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#isVerticalOffsetEnabled()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#layoutDependsOn(CoordinatorLayout,View,View)(CoordinatorLayout parent, View child, View dependency)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#onDependentViewChanged(CoordinatorLayout,View,View)( CoordinatorLayout parent, View child, View dependency )` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#onDependentViewRemoved(CoordinatorLayout,View,View)( CoordinatorLayout parent, View child, View dependency )` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#onLayoutChild(CoordinatorLayout,V,int)(CoordinatorLayout parent, V child, int layoutDirection)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#onMeasureChild(CoordinatorLayout,View,int,int,int,int)( CoordinatorLayout parent, View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed )` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#onRequestChildRectangleOnScreen(CoordinatorLayout,View,Rect,boolean)( CoordinatorLayout parent, View child, Rect rectangle, boolean immediate )` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#setHorizontalOffsetEnabled(boolean)(boolean horizontalOffsetEnabled)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#setLeftAndRightOffset(int)(int offset)` |
| `final void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#setOverlayTop(int)(int overlayTop)` Set the distance that this view should overlap any `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#setTopAndBottomOffset(int)(int offset)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#setVerticalOffsetEnabled(boolean)(boolean verticalOffsetEnabled)` |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#layoutChild(CoordinatorLayout,View,int)(CoordinatorLayout parent, View child, int layoutDirection)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#layoutChild(CoordinatorLayout,V,int)(CoordinatorLayout parent, V child, int layoutDirection)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#shouldHeaderOverlapScrollingChild()()` |

## Public fields

### overlayTop

```
public int overlayTop
```

## Public constructors

### ScrollingViewBehavior

```
public ScrollingViewBehavior()
```

### ScrollingViewBehavior

```
public ScrollingViewBehavior(Context context, AttributeSet attrs)
```

## Public methods

### getLeftAndRightOffset

```
public int getLeftAndRightOffset()
```

### getOverlayTop

```
public final int getOverlayTop()
```

Returns the distance that this view should overlap any `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`.

### getTopAndBottomOffset

```
public int getTopAndBottomOffset()
```

### isHorizontalOffsetEnabled

```
public boolean isHorizontalOffsetEnabled()
```

### isVerticalOffsetEnabled

```
public boolean isVerticalOffsetEnabled()
```

### layoutDependsOn

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

### onDependentViewChanged

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

### onDependentViewRemoved

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

### onLayoutChild

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

### onMeasureChild

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

### onRequestChildRectangleOnScreen

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

### setHorizontalOffsetEnabled

```
public void setHorizontalOffsetEnabled(boolean horizontalOffsetEnabled)
```

### setLeftAndRightOffset

```
public boolean setLeftAndRightOffset(int offset)
```

### setOverlayTop

```
public final void setOverlayTop(int overlayTop)
```

Set the distance that this view should overlap any `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`.

| Parameters |
|---|---|
| `int overlayTop` | the distance in px |

### setTopAndBottomOffset

```
public boolean setTopAndBottomOffset(int offset)
```

### setVerticalOffsetEnabled

```
public void setVerticalOffsetEnabled(boolean verticalOffsetEnabled)
```

## Protected methods

### layoutChild

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

### layoutChild

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

### shouldHeaderOverlapScrollingChild

```
protected boolean shouldHeaderOverlapScrollingChild()
```