# SearchBar.ScrollingViewBehavior

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

*** ** * ** ***


```
public class SearchBar.ScrollingViewBehavior extends AppBarLayout.ScrollingViewBehavior
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [com.google.android.material.appbar.AppBarLayout.ScrollingViewBehavior](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior) ||
|   | ↳ | [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`.

## Summary

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

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

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/com/google/android/material/search/SearchBar.ScrollingViewBehavior#getLeftAndRightOffset()()` |
| `final int` | `https://developer.android.com/reference/com/google/android/material/search/SearchBar.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/search/SearchBar.ScrollingViewBehavior#getTopAndBottomOffset()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/search/SearchBar.ScrollingViewBehavior#isHorizontalOffsetEnabled()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/search/SearchBar.ScrollingViewBehavior#isVerticalOffsetEnabled()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/search/SearchBar.ScrollingViewBehavior#onDependentViewChanged(CoordinatorLayout,View,View)( CoordinatorLayout parent, View child, View dependency )` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/search/SearchBar.ScrollingViewBehavior#onLayoutChild(CoordinatorLayout,V,int)(CoordinatorLayout parent, V child, int layoutDirection)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/search/SearchBar.ScrollingViewBehavior#onMeasureChild(CoordinatorLayout,View,int,int,int,int)( CoordinatorLayout parent, View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed )` |
| `void` | `https://developer.android.com/reference/com/google/android/material/search/SearchBar.ScrollingViewBehavior#setHorizontalOffsetEnabled(boolean)(boolean horizontalOffsetEnabled)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/search/SearchBar.ScrollingViewBehavior#setLeftAndRightOffset(int)(int offset)` |
| `final void` | `https://developer.android.com/reference/com/google/android/material/search/SearchBar.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/search/SearchBar.ScrollingViewBehavior#setTopAndBottomOffset(int)(int offset)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/search/SearchBar.ScrollingViewBehavior#setVerticalOffsetEnabled(boolean)(boolean verticalOffsetEnabled)` |

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

| ### Inherited methods |
|---|
| From [com.google.android.material.appbar.AppBarLayout.ScrollingViewBehavior](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior) |---|---| | `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior#layoutDependsOn(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#onRequestChildRectangleOnScreen(CoordinatorLayout,View,Rect,boolean)( CoordinatorLayout parent, View child, Rect rectangle, boolean immediate )` | |

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

### onDependentViewChanged

```
public boolean onDependentViewChanged(
    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
)
```

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