# AppBarLayout

[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
```

<br />

*** ** * ** ***

AppBarLayout is a vertical LinearLayout which implements many of the features of material designs app bar concept, namely scrolling gestures.

Children should provide their desired scrolling behavior through `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LayoutParams#setScrollFlags(int)` and the associated layout xml attribute: `
app:layout_scrollFlags`.

This view depends heavily on being used as a direct child within a CoordinatorLayout. If you use AppBarLayout within a different ViewGroup, most of its functionality will not work.

AppBarLayout also requires a separate scrolling sibling in order to know when to scroll. The binding is done through the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior` behavior class, meaning that you should set your scrolling view's behavior to be an instance of `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior`. A string resource containing the full class name is available.

```
<androidx.coordinatorlayout.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <!-- Your scrolling content -->

    </androidx.core.widget.NestedScrollView>

    <com.google.android.material.appbar.AppBarLayout
            android:layout_height="wrap_content"
            android:layout_width="match_parent">

        <androidx.appcompat.widget.Toolbar
                ...
                app:layout_scrollFlags="scroll|enterAlways"/>

        <com.google.android.material.tabs.TabLayout
                ...
                app:layout_scrollFlags="scroll|enterAlways"/>

    </com.google.android.material.appbar.AppBarLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
```

For more information, see the [component developer guidance](https://github.com/material-components/material-components-android/blob/master/docs/components/TopAppBar.md) and [design guidelines](https://material.io/components/top-app-bar/overview).

## Summary

| ### Nested types |
|---|
| `protected class https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.BaseBehavior<T extends https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout>` The default `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.Behavior` for `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`. |
| `public abstract class https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.BaseBehavior.BaseDragCallback<T extends https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout>` Callback to allow control over any `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` dragging. |
| `protected class https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.BaseBehavior.SavedState` A Parcelable implementation for `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`. |
| `public interface https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.BaseOnOffsetChangedListener<T extends https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout>` Interface definition for a callback to be invoked when an `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`'s vertical offset changes. |
| `public class https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.Behavior extends https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.BaseBehavior` The default `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.Behavior` for `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`. |
| `public abstract class https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.Behavior.DragCallback extends https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.BaseBehavior.BaseDragCallback` Callback to allow control over any `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` dragging. |
| `public abstract class https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ChildScrollEffect` An effect class that should be implemented and used by AppBarLayout children to be given effects when the AppBarLayout's offset changes. |
| `public class https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.CompressChildScrollEffect extends https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ChildScrollEffect` A class which handles updating an AppBarLayout child, if marked with the ` app:layout_scrollEffect``compress`, at each step in the `AppBarLayout`'s offset animation. |
| `public class https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LayoutParams` A ViewGroup.LayoutParams implementation for `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`. |
| `public interface https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollListener` **This interface is deprecated.** Use `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollProgressListener` instead <br /> |
| `public abstract class https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollProgressListener` Definition for a callback to be invoked when the lift on scroll progress has changed. |
| `public interface https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.OnOffsetChangedListener extends https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.BaseOnOffsetChangedListener` Interface definition for a callback to be invoked when an `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`'s vertical offset changes. |
| `public class https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.ScrollingViewBehavior` 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. |

| ### Public fields |
|---|---|
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#liftOnScrollTargetViewId()` |
| `Drawable` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#statusBarForeground()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#totalScrollRange()` |

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

| ### Public methods |
|---|---|
| `void` | `[addLiftOnScrollListener](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#addLiftOnScrollListener(com.google.android.material.appbar.AppBarLayout.LiftOnScrollListener))( https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollListener liftOnScrollListener )` **This method is deprecated.** Use `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#addLiftOnScrollProgressListener(com.google.android.material.appbar.AppBarLayout.LiftOnScrollProgressListener)` instead. <br /> |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#addLiftOnScrollProgressListener(com.google.android.material.appbar.AppBarLayout.LiftOnScrollProgressListener)( https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollProgressListener liftProgressListener )` Add a `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollProgressListener` that will be called when the lift on scroll progress changes |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#addOnOffsetChangedListener(com.google.android.material.appbar.AppBarLayout.BaseOnOffsetChangedListener)( https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.BaseOnOffsetChangedListener listener )` Add a listener that will be called when the offset of this `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` changes. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#addOnOffsetChangedListener(com.google.android.material.appbar.AppBarLayout.OnOffsetChangedListener)( https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.OnOffsetChangedListener listener )` |
| `void` | `[clearLiftOnScrollListener](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#clearLiftOnScrollListener())()` **This method is deprecated.** Use `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#clearLiftOnScrollProgressListener()` instead. <br /> |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#clearLiftOnScrollProgressListener()()` Remove all previously added `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollProgressListener`s. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#draw(Canvas)(Canvas canvas)` |
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LayoutParams` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#generateLayoutParams(AttributeSet)(AttributeSet attrs)` |
| `Behavior<AppBarLayout>` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#getBehavior()()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#getLiftOnScrollTargetViewId()()` Returns the id of the view that the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` should use to determine whether it should be lifted. |
| `https://developer.android.com/reference/com/google/android/material/shape/MaterialShapeDrawable` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#getMaterialShapeBackground()()` |
| `final int` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#getMinimumHeightForVisibleOverlappingContent()()` |
| `Drawable` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#getStatusBarForeground()()` Returns the drawable which is used for the status bar foreground. |
| `float` | `[getTargetElevation](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#getTargetElevation())()` **This method is deprecated.** target elevation is now deprecated. <br /> |
| `final int` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#getTotalScrollRange()()` Returns the scroll range of all children. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#isLiftOnScroll()()` Returns whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` lifts on scroll or not. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#isLifted()()` Returns whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` is in a lifted state or not. |
| `boolean` | `[removeLiftOnScrollListener](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#removeLiftOnScrollListener(com.google.android.material.appbar.AppBarLayout.LiftOnScrollListener))( https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollListener liftOnScrollListener )` **This method is deprecated.** Use `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#removeLiftOnScrollProgressListener(com.google.android.material.appbar.AppBarLayout.LiftOnScrollProgressListener)` instead. <br /> |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#removeLiftOnScrollProgressListener(com.google.android.material.appbar.AppBarLayout.LiftOnScrollProgressListener)( https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollProgressListener liftProgressListener )` Remove a previously added `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollProgressListener`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#removeOnOffsetChangedListener(com.google.android.material.appbar.AppBarLayout.BaseOnOffsetChangedListener)( https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.BaseOnOffsetChangedListener listener )` Remove the previously added `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.OnOffsetChangedListener`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#removeOnOffsetChangedListener(com.google.android.material.appbar.AppBarLayout.OnOffsetChangedListener)( https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.OnOffsetChangedListener listener )` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setBackground(Drawable)(Drawable background)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setElevation(float)(float elevation)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setExpanded(boolean)(boolean expanded)` Sets whether this `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` is expanded or not, animating if it has already been laid out. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setExpanded(boolean,boolean)(boolean expanded, boolean animate)` Sets whether this `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` is expanded or not. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLiftOnScroll(boolean)(boolean liftOnScroll)` Sets whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` lifts on scroll or not. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLiftOnScrollColor(ColorStateList)(ColorStateList liftOnScrollColor)` Sets the color of the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` when it is fully lifted. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLiftOnScrollTargetView(View)(View liftOnScrollTargetView)` Sets the view that the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` should use to determine whether it should be lifted. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLiftOnScrollTargetViewId(int)(int liftOnScrollTargetViewId)` Sets the id of the view that the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` should use to determine whether it should be lifted. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLiftable(boolean)(boolean liftable)` Sets whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` is liftable or not. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLiftableOverrideEnabled(boolean)(boolean enabled)` Sets whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` lifted state corresponding to `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLiftable(boolean)` and `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLifted(boolean)` will be overridden manually. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLifted(boolean)(boolean lifted)` Sets whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` is in a lifted state or not. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setOrientation(int)(int orientation)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setStatusBarForeground(Drawable)(Drawable drawable)` Set the drawable to use for the status bar foreground drawable. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setStatusBarForegroundColor(int)(int color)` Set the color to use for the status bar foreground. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setStatusBarForegroundResource(int)(int resId)` Set the drawable to use for the status bar foreground from resources. |
| `void` | `[setTargetElevation](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setTargetElevation(float))(float elevation)` **This method is deprecated.** target elevation is now deprecated. <br /> |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setVisibility(int)(int visibility)` |

| ### Protected methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#checkLayoutParams(ViewGroup.LayoutParams)(LayoutParams p)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#drawableStateChanged()()` |
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LayoutParams` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#generateDefaultLayoutParams()()` |
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LayoutParams` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#generateLayoutParams(ViewGroup.LayoutParams)(LayoutParams p)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#onAttachedToWindow()()` |
| `int[]` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#onCreateDrawableState(int)(int extraSpace)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#onDetachedFromWindow()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#onLayout(boolean,int,int,int,int)(boolean changed, int l, int t, int r, int b)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#onMeasure(int,int)(int widthMeasureSpec, int heightMeasureSpec)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#verifyDrawable(Drawable)(Drawable who)` |

## Public fields

### liftOnScrollTargetViewId

```
public int liftOnScrollTargetViewId
```

### statusBarForeground

```
public Drawable statusBarForeground
```

### totalScrollRange

```
public int totalScrollRange
```

## Public constructors

### AppBarLayout

```
public AppBarLayout(Context context)
```

### AppBarLayout

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

### AppBarLayout

```
public AppBarLayout(Context context, AttributeSet attrs, int defStyleAttr)
```

## Public methods

### addLiftOnScrollListener

```
public void [addLiftOnScrollListener](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#addLiftOnScrollListener(com.google.android.material.appbar.AppBarLayout.LiftOnScrollListener))(
    AppBarLayout.LiftOnScrollListener liftOnScrollListener
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#addLiftOnScrollProgressListener(com.google.android.material.appbar.AppBarLayout.LiftOnScrollProgressListener)` instead.

Add a `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollListener` that will be called when the lift on scroll elevation and background color of this `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` change.

### addLiftOnScrollProgressListener

```
public void addLiftOnScrollProgressListener(
    AppBarLayout.LiftOnScrollProgressListener liftProgressListener
)
```

Add a `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollProgressListener` that will be called when the lift on scroll progress changes

### addOnOffsetChangedListener

```
public void addOnOffsetChangedListener(
    AppBarLayout.BaseOnOffsetChangedListener listener
)
```

Add a listener that will be called when the offset of this `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` changes.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.BaseOnOffsetChangedListener listener` | The listener that will be called when the offset changes.\] |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#removeOnOffsetChangedListener(com.google.android.material.appbar.AppBarLayout.OnOffsetChangedListener)` |   |

### addOnOffsetChangedListener

```
public void addOnOffsetChangedListener(
    AppBarLayout.OnOffsetChangedListener listener
)
```

### clearLiftOnScrollListener

```
public void [clearLiftOnScrollListener](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#clearLiftOnScrollListener())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#clearLiftOnScrollProgressListener()` instead.

Remove all previously added `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollListener`s.

### clearLiftOnScrollProgressListener

```
public void clearLiftOnScrollProgressListener()
```

Remove all previously added `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollProgressListener`s.

### draw

```
public void draw(Canvas canvas)
```

### generateLayoutParams

```
public AppBarLayout.LayoutParams generateLayoutParams(AttributeSet attrs)
```

### getBehavior

```
public Behavior<AppBarLayout> getBehavior()
```

### getLiftOnScrollTargetViewId

```
public int getLiftOnScrollTargetViewId()
```

Returns the id of the view that the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` should use to determine whether it should be lifted.

### getMaterialShapeBackground

```
public MaterialShapeDrawable getMaterialShapeBackground()
```

### getMinimumHeightForVisibleOverlappingContent

```
public final int getMinimumHeightForVisibleOverlappingContent()
```

### getStatusBarForeground

```
public Drawable getStatusBarForeground()
```

Returns the drawable which is used for the status bar foreground.

ref R.styleable#AppBarLayout_statusBarForeground

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setStatusBarForeground(Drawable)` |   |

### getTargetElevation

```
public float [getTargetElevation](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#getTargetElevation())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> target elevation is now deprecated. AppBarLayout's elevation is now controlled via a android.animation.StateListAnimator. This method now always returns 0.

### getTotalScrollRange

```
public final int getTotalScrollRange()
```

Returns the scroll range of all children.

| Returns |
|---|---|
| `int` | the scroll range in px |

### isLiftOnScroll

```
public boolean isLiftOnScroll()
```

Returns whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` lifts on scroll or not.

### isLifted

```
public boolean isLifted()
```

Returns whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` is in a lifted state or not.

### removeLiftOnScrollListener

```
public boolean [removeLiftOnScrollListener](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#removeLiftOnScrollListener(com.google.android.material.appbar.AppBarLayout.LiftOnScrollListener))(
    AppBarLayout.LiftOnScrollListener liftOnScrollListener
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#removeLiftOnScrollProgressListener(com.google.android.material.appbar.AppBarLayout.LiftOnScrollProgressListener)` instead.

Remove a previously added `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollListener`.

### removeLiftOnScrollProgressListener

```
public boolean removeLiftOnScrollProgressListener(
    AppBarLayout.LiftOnScrollProgressListener liftProgressListener
)
```

Remove a previously added `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.LiftOnScrollProgressListener`.

### removeOnOffsetChangedListener

```
public void removeOnOffsetChangedListener(
    AppBarLayout.BaseOnOffsetChangedListener listener
)
```

Remove the previously added `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.OnOffsetChangedListener`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout.BaseOnOffsetChangedListener listener` | the listener to remove. |

### removeOnOffsetChangedListener

```
public void removeOnOffsetChangedListener(
    AppBarLayout.OnOffsetChangedListener listener
)
```

### setBackground

```
public void setBackground(Drawable background)
```

### setElevation

```
public void setElevation(float elevation)
```

### setExpanded

```
public void setExpanded(boolean expanded)
```

Sets whether this `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` is expanded or not, animating if it has already been laid out.

As with `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`'s scrolling, this method relies on this layout being a direct child of a CoordinatorLayout.

ref com.google.android.material.R.styleable#AppBarLayout_expanded

| Parameters |
|---|---|
| `boolean expanded` | true if the layout should be fully expanded, false if it should be fully collapsed |

### setExpanded

```
public void setExpanded(boolean expanded, boolean animate)
```

Sets whether this `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` is expanded or not.

As with `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`'s scrolling, this method relies on this layout being a direct child of a CoordinatorLayout.

ref com.google.android.material.R.styleable#AppBarLayout_expanded

| Parameters |
|---|---|
| `boolean expanded` | true if the layout should be fully expanded, false if it should be fully collapsed |
| `boolean animate` | Whether to animate to the new state |

### setLiftOnScroll

```
public void setLiftOnScroll(boolean liftOnScroll)
```

Sets whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` lifts on scroll or not.

If set to true, the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` will animate to the lifted, or elevated, state when content is scrolled beneath it. Requires \`app:layout_behavior="@string/appbar_scrolling_view_behavior\` to be set on the scrolling sibling (e.g., \`NestedScrollView\`, \`RecyclerView\`, etc.).

### setLiftOnScrollColor

```
public void setLiftOnScrollColor(ColorStateList liftOnScrollColor)
```

Sets the color of the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` when it is fully lifted.

### setLiftOnScrollTargetView

```
public void setLiftOnScrollTargetView(View liftOnScrollTargetView)
```

Sets the view that the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` should use to determine whether it should be lifted.

### setLiftOnScrollTargetViewId

```
public void setLiftOnScrollTargetViewId(int liftOnScrollTargetViewId)
```

Sets the id of the view that the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` should use to determine whether it should be lifted.

### setLiftable

```
public boolean setLiftable(boolean liftable)
```

Sets whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` is liftable or not.

| Returns |
|---|---|
| `boolean` | true if the liftable state changed |

### setLiftableOverrideEnabled

```
public void setLiftableOverrideEnabled(boolean enabled)
```

Sets whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` lifted state corresponding to `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLiftable(boolean)` and `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLifted(boolean)` will be overridden manually.

If true, this means that the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` will not manage its own lifted state and it should instead be manually updated via `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLifted(boolean)`. If false, the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` will manage its lifted state based on the scrolling sibling view.

Note that calling `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setLiftable(boolean)` will result in this liftable override being enabled and set to true by default.

### setLifted

```
public boolean setLifted(boolean lifted)
```

Sets whether the `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout` is in a lifted state or not.

| Returns |
|---|---|
| `boolean` | true if the lifted state changed |

### setOrientation

```
public void setOrientation(int orientation)
```

### setStatusBarForeground

```
public void setStatusBarForeground(Drawable drawable)
```

Set the drawable to use for the status bar foreground drawable. Providing null will disable the scrim functionality.

This scrim is only shown when we have been given a top system inset.

ref R.styleable#AppBarLayout_statusBarForeground

| Parameters |
|---|---|
| `Drawable drawable` | the drawable to display |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#getStatusBarForeground()` |   |

### setStatusBarForegroundColor

```
public void setStatusBarForegroundColor(int color)
```

Set the color to use for the status bar foreground.

This scrim is only shown when we have been given a top system inset.

ref R.styleable#AppBarLayout_statusBarForeground

| Parameters |
|---|---|
| `int color` | the color to display |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#getStatusBarForeground()` |   |

### setStatusBarForegroundResource

```
public void setStatusBarForegroundResource(int resId)
```

Set the drawable to use for the status bar foreground from resources.

This scrim is only shown when we have been given a top system inset.

ref R.styleable#AppBarLayout_statusBarForeground

| Parameters |
|---|---|
| `int resId` | drawable resource id |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#getStatusBarForeground()` |   |

### setTargetElevation

```
public void [setTargetElevation](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setTargetElevation(float))(float elevation)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> target elevation is now deprecated. AppBarLayout's elevation is now controlled via a android.animation.StateListAnimator. If a target elevation is set, either by this method or the `app:elevation` attribute, a new state list animator is created which uses the given `elevation` value.

ref com.google.android.material.R.styleable#AppBarLayout_elevation

### setVisibility

```
public void setVisibility(int visibility)
```

## Protected methods

### checkLayoutParams

```
protected boolean checkLayoutParams(LayoutParams p)
```

### drawableStateChanged

```
protected void drawableStateChanged()
```

### generateDefaultLayoutParams

```
protected AppBarLayout.LayoutParams generateDefaultLayoutParams()
```

### generateLayoutParams

```
protected AppBarLayout.LayoutParams generateLayoutParams(LayoutParams p)
```

### onAttachedToWindow

```
protected void onAttachedToWindow()
```

### onCreateDrawableState

```
protected int[] onCreateDrawableState(int extraSpace)
```

### onDetachedFromWindow

```
protected void onDetachedFromWindow()
```

### onLayout

```
protected void onLayout(boolean changed, int l, int t, int r, int b)
```

### onMeasure

```
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
```

### verifyDrawable

```
protected boolean verifyDrawable(Drawable who)
```