# CollapsingToolbarLayout

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

*** ** * ** ***


```
public class CollapsingToolbarLayout
```

<br />

*** ** * ** ***

CollapsingToolbarLayout is a wrapper for `Toolbar` which implements a collapsing app bar. It is designed to be used as a direct child of a `https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout`. CollapsingToolbarLayout contains the following features:
Collapsing title A title which is larger when the layout is fully visible but collapses and becomes smaller as the layout is scrolled off screen. You can set the title to display via `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitle(java.lang.CharSequence)`. The title appearance can be tweaked via the `
collapsedTextAppearance` and `expandedTextAppearance` attributes. Content scrim A full-bleed scrim which is show or hidden when the scroll position has hit a certain threshold. You can change this via `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setContentScrim(Drawable)`. Status bar scrim A scrim which is shown or hidden behind the status bar when the scroll position has hit a certain threshold. You can change this via `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setStatusBarScrim(Drawable)`. This only works on LOLLIPOP devices when we set to fit system windows. Parallax scrolling children Child views can opt to be scrolled within this layout in a parallax fashion. See `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.LayoutParams#COLLAPSE_MODE_PARALLAX()` and `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.LayoutParams#setParallaxMultiplier(float)`. Pinned position children Child views can opt to be pinned in space globally. This is useful when implementing a collapsing as it allows the `Toolbar` to be fixed in place even though this layout is moving. See `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.LayoutParams#COLLAPSE_MODE_PIN()`.

**Do not manually add views to the Toolbar at run time**. We will add a 'dummy view' to the Toolbar which allows us to work out the available space for the title. This can interfere with any views which you add.

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

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

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

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

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

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

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

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

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

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

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.LayoutParams` |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#TITLE_COLLAPSE_MODE_FADE() = 1` The expanded title will fade out and translate, and the collapsed title will fade in. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#TITLE_COLLAPSE_MODE_SCALE() = 0` The expanded title will continuously scale and translate to its final collapsed position. |

| ### Public fields |
|---|---|
| `Drawable` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#contentScrim()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#expandedTitleSpacing()` |
| `long` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#scrimAnimationDuration()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#scrimVisibleHeightTrigger()` |
| `Drawable` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#statusBarScrim()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#titleCollapseMode()` |

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

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#draw(Canvas)(Canvas canvas)` |
| `LayoutParams` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#generateLayoutParams(AttributeSet)(AttributeSet attrs)` |
| `float` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getCollapsedSubtitleTextSize()()` Returns the text size of the collapsed subtitle. |
| `Typeface` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getCollapsedSubtitleTypeface()()` Returns the typeface used for the collapsed subtitle. |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getCollapsedTitleGravity()()` Returns the horizontal and vertical alignment for titles when collapsed. |
| `float` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getCollapsedTitleTextSize()()` Returns the text size of the collapsed title. |
| `Typeface` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getCollapsedTitleTypeface()()` Returns the typeface used for the collapsed title. |
| `Drawable` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getContentScrim()()` Returns the drawable which is used for the foreground scrim. |
| `float` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedSubtitleTextSize()()` Returns the text size of the expanded subtitle. |
| `Typeface` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedSubtitleTypeface()()` Returns the typeface used for the expanded subtitle. |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleGravity()()` Returns the horizontal and vertical alignment for titles when expanded. |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleMarginBottom()()` ref com.google.android.material.R.styleable#CollapsingToolbarLayout_expandedTitleMarginBottom |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleMarginEnd()()` ref com.google.android.material.R.styleable#CollapsingToolbarLayout_expandedTitleMarginEnd |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleMarginStart()()` ref com.google.android.material.R.styleable#CollapsingToolbarLayout_expandedTitleMarginStart |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleMarginTop()()` ref com.google.android.material.R.styleable#CollapsingToolbarLayout_expandedTitleMarginTop |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleSpacing()()` Returns the spacing between the expanded title and subtitle in pixels |
| `float` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleTextSize()()` Returns the text size of the expanded title. |
| `Typeface` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleTypeface()()` Returns the typeface used for the expanded title. |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getHyphenationFrequency()()` Gets the hyphenation frequency of the title text, or -1 if not set. |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getLineCount()()` Gets the current number of lines of the title text. |
| `float` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getLineSpacingAdd()()` Gets the line spacing addition of the title text, or -1 if not set. |
| `float` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getLineSpacingMultiplier()()` Gets the line spacing multiplier of the title text, or -1 if not set. |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getMaxLines()()` Gets the maximum number of lines to display in the expanded state. |
| `long` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getScrimAnimationDuration()()` Returns the duration in milliseconds used for scrim visibility animations. |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getScrimVisibleHeightTrigger()()` Returns the amount of visible height in pixels used to define when to trigger a scrim visibility change. |
| `Drawable` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getStatusBarScrim()()` Returns the drawable which is used for the status bar scrim. |
| `https://developer.android.com/reference/java/lang/CharSequence` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getSubtitle()()` Returns the subtitle currently being displayed by this view. |
| `https://developer.android.com/reference/java/lang/CharSequence` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getTitle()()` Returns the title currently being displayed by this view. |
| `int` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getTitleCollapseMode()()` Returns the current title collapse mode. |
| `TimeInterpolator` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getTitlePositionInterpolator()()` Returns the interpolator being used to animate the title position from collapsed to expanded and vice versa. |
| `TruncateAt` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getTitleTextEllipsize()()` Get ellipsizing currently applied on the title text. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#isExtraMultilineHeightEnabled()()` Gets whether extra height should be added when the title text spans across multiple lines. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#isForceApplySystemWindowInsetTop()()` Gets whether the top system window inset should be respected regardless of what the ` layout_height` of the `CollapsingToolbarLayout` is set to. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#isRtlTextDirectionHeuristicsEnabled()()` Gets whether `TextDirectionHeuristics` should be used to determine whether the title text is RTL. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#isTitleEnabled()()` Returns whether this view is currently displaying its own title. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setCollapsedSubtitleTextAppearance(int)(int resId)` Sets the text color and size for the collapsed subtitle from the specified TextAppearance resource. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setCollapsedSubtitleTextColor(int)(int color)` Sets the text color of the collapsed subtitle. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setCollapsedSubtitleTextColor(ColorStateList)(ColorStateList colors)` Sets the text colors of the collapsed subtitle. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setCollapsedSubtitleTextSize(float)(float textSize)` Sets the text size of the collapsed subtitle. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setCollapsedSubtitleTypeface(Typeface)(Typeface typeface)` Set the typeface to use for the collapsed subtitle. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setCollapsedTitleGravity(int)(int gravity)` Sets the horizontal alignment of the collapsed titles and the vertical gravity that will be used when there is extra space in the collapsed bounds beyond what is required for the title itself. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setCollapsedTitleTextAppearance(int)(int resId)` Sets the text color and size for the collapsed title from the specified TextAppearance resource. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setCollapsedTitleTextColor(int)(int color)` Sets the text color of the collapsed title. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setCollapsedTitleTextColor(ColorStateList)(ColorStateList colors)` Sets the text colors of the collapsed title. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setCollapsedTitleTextSize(float)(float textSize)` Sets the text size of the collapsed title. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setCollapsedTitleTypeface(Typeface)(Typeface typeface)` Set the typeface to use for the collapsed title. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setContentScrim(Drawable)(Drawable drawable)` Set the drawable to use for the content scrim from resources. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setContentScrimColor(int)(int color)` Set the color to use for the content scrim. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setContentScrimResource(int)(int resId)` Set the drawable to use for the content scrim from resources. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedSubtitleColor(int)(int color)` Sets the text color of the expanded subtitle. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedSubtitleTextAppearance(int)(int resId)` Sets the text color and size for the expanded subtitle from the specified TextAppearance resource. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedSubtitleTextColor(ColorStateList)(ColorStateList colors)` Sets the text colors of the expanded subtitle. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedSubtitleTextSize(float)(float textSize)` Sets the text size of the expanded subtitle. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedSubtitleTypeface(Typeface)(Typeface typeface)` Set the typeface to use for the expanded subtitle. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleColor(int)(int color)` Sets the text color of the expanded title. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleGravity(int)(int gravity)` Sets the horizontal alignment of the expanded titles and the vertical gravity that will be used when there is extra space in the expanded bounds beyond what is required for the title itself. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleMargin(int,int,int,int)(int start, int top, int end, int bottom)` Sets the expanded title margins. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleMarginBottom(int)(int margin)` Sets the bottom expanded title margin in pixels. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleMarginEnd(int)(int margin)` Sets the ending expanded title margin in pixels. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleMarginStart(int)(int margin)` Sets the starting expanded title margin in pixels. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleMarginTop(int)(int margin)` Sets the top expanded title margin in pixels. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleSpacing(int)(int titleSpacing)` Sets the spacing between the expanded title and subtitle. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleTextAppearance(int)(int resId)` Sets the text color and size for the expanded title from the specified TextAppearance resource. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleTextColor(ColorStateList)(ColorStateList colors)` Sets the text colors of the expanded title. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleTextSize(float)(float textSize)` Sets the text size of the expanded title. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleTypeface(Typeface)(Typeface typeface)` Set the typeface to use for the expanded title. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExtraMultilineHeightEnabled(boolean)(boolean extraMultilineHeightEnabled)` Sets whether extra height should be added when the title text spans across multiple lines. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setForceApplySystemWindowInsetTop(boolean)( boolean forceApplySystemWindowInsetTop )` Sets whether the top system window inset should be respected regardless of what the ` layout_height` of the `CollapsingToolbarLayout` is set to. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setHyphenationFrequency(int)(int hyphenationFrequency)` Sets the hyphenation frequency of the title text. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setLineSpacingAdd(float)(float spacingAdd)` Sets the line spacing addition of the title text. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setLineSpacingMultiplier(float)(float spacingMultiplier)` Sets the line spacing multiplier of the title text. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setMaxLines(int)(int maxLines)` Sets the maximum number of lines to display in the expanded state. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setRtlTextDirectionHeuristicsEnabled(boolean)( boolean rtlTextDirectionHeuristicsEnabled )` Sets whether `TextDirectionHeuristics` should be used to determine whether the title text is RTL. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setScrimAnimationDuration(long)(long duration)` Set the duration used for scrim visibility animations. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setScrimVisibleHeightTrigger(int)(int height)` Set the amount of visible height in pixels used to define when to trigger a scrim visibility change. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setScrimsShown(boolean)(boolean shown)` Set whether the content scrim and/or status bar scrim should be shown or not. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setScrimsShown(boolean,boolean)(boolean shown, boolean animate)` Set whether the content scrim and/or status bar scrim should be shown or not. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setStatusBarScrim(Drawable)(Drawable drawable)` Set the drawable to use for the status bar scrim from resources. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setStatusBarScrimColor(int)(int color)` Set the color to use for the status bar scrim. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setStatusBarScrimResource(int)(int resId)` Set the drawable to use for the status bar scrim from resources. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setSubtitle(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence subtitle)` Sets the subtitle to be displayed by this view, if enabled. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitle(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence title)` Sets the title to be displayed by this view, if enabled. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitleCollapseMode(int)(int titleCollapseMode)` Sets the title collapse mode which determines the effect used to collapse and expand the title text. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitleEllipsize(TruncateAt)(TruncateAt ellipsize)` Set ellipsizing on the title text. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitleEnabled(boolean)(boolean enabled)` Sets whether this view should display its own title. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitlePositionInterpolator(TimeInterpolator)(TimeInterpolator interpolator)` Sets the interpolator to use when animating the title position from collapsed to expanded and vice versa. |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setVisibility(int)(int visibility)` |

| ### Protected methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#checkLayoutParams(ViewGroup.LayoutParams)(LayoutParams p)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#drawChild(Canvas,View,long)(Canvas canvas, View child, long drawingTime)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#drawableStateChanged()()` |
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout.LayoutParams` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#generateDefaultLayoutParams()()` |
| `LayoutParams` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#generateLayoutParams(ViewGroup.LayoutParams)(LayoutParams p)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#onAttachedToWindow()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#onConfigurationChanged(Configuration)(Configuration newConfig)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#onDetachedFromWindow()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#onLayout(boolean,int,int,int,int)(boolean changed, int left, int top, int right, int bottom)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#onMeasure(int,int)(int widthMeasureSpec, int heightMeasureSpec)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#onSizeChanged(int,int,int,int)(int w, int h, int oldw, int oldh)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#verifyDrawable(Drawable)(Drawable who)` |

## Constants

### TITLE_COLLAPSE_MODE_FADE

```
public static final int TITLE_COLLAPSE_MODE_FADE = 1
```

The expanded title will fade out and translate, and the collapsed title will fade in.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitleCollapseMode(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getTitleCollapseMode()` |   |

### TITLE_COLLAPSE_MODE_SCALE

```
public static final int TITLE_COLLAPSE_MODE_SCALE = 0
```

The expanded title will continuously scale and translate to its final collapsed position.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitleCollapseMode(int)` |   |
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getTitleCollapseMode()` |   |

## Public fields

### contentScrim

```
public Drawable contentScrim
```

### expandedTitleSpacing

```
public int expandedTitleSpacing
```

### scrimAnimationDuration

```
public long scrimAnimationDuration
```

### scrimVisibleHeightTrigger

```
public int scrimVisibleHeightTrigger
```

### statusBarScrim

```
public Drawable statusBarScrim
```

### titleCollapseMode

```
public int titleCollapseMode
```

## Public constructors

### CollapsingToolbarLayout

```
public CollapsingToolbarLayout(Context context)
```

### CollapsingToolbarLayout

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

### CollapsingToolbarLayout

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

## Public methods

### draw

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

### generateLayoutParams

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

### getCollapsedSubtitleTextSize

```
public float getCollapsedSubtitleTextSize()
```

Returns the text size of the collapsed subtitle.

### getCollapsedSubtitleTypeface

```
public Typeface getCollapsedSubtitleTypeface()
```

Returns the typeface used for the collapsed subtitle.

### getCollapsedTitleGravity

```
public int getCollapsedTitleGravity()
```

Returns the horizontal and vertical alignment for titles when collapsed.

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

### getCollapsedTitleTextSize

```
public float getCollapsedTitleTextSize()
```

Returns the text size of the collapsed title.

### getCollapsedTitleTypeface

```
public Typeface getCollapsedTitleTypeface()
```

Returns the typeface used for the collapsed title.

### getContentScrim

```
public Drawable getContentScrim()
```

Returns the drawable which is used for the foreground scrim.

ref R.styleable#CollapsingToolbarLayout_contentScrim

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

### getExpandedSubtitleTextSize

```
public float getExpandedSubtitleTextSize()
```

Returns the text size of the expanded subtitle.

### getExpandedSubtitleTypeface

```
public Typeface getExpandedSubtitleTypeface()
```

Returns the typeface used for the expanded subtitle.

### getExpandedTitleGravity

```
public int getExpandedTitleGravity()
```

Returns the horizontal and vertical alignment for titles when expanded.

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

### getExpandedTitleMarginBottom

```
public int getExpandedTitleMarginBottom()
```

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

| Returns |
|---|---|
| `int` | the bottom expanded title margin in pixels |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleMarginBottom(int)` |   |

### getExpandedTitleMarginEnd

```
public int getExpandedTitleMarginEnd()
```

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

| Returns |
|---|---|
| `int` | the ending expanded title margin in pixels |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleMarginEnd(int)` |   |

### getExpandedTitleMarginStart

```
public int getExpandedTitleMarginStart()
```

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

| Returns |
|---|---|
| `int` | the starting expanded title margin in pixels |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleMarginStart(int)` |   |

### getExpandedTitleMarginTop

```
public int getExpandedTitleMarginTop()
```

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

| Returns |
|---|---|
| `int` | the top expanded title margin in pixels |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleMarginTop(int)` |   |

### getExpandedTitleSpacing

```
public int getExpandedTitleSpacing()
```

Returns the spacing between the expanded title and subtitle in pixels

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

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setExpandedTitleSpacing(int)` |   |

### getExpandedTitleTextSize

```
public float getExpandedTitleTextSize()
```

Returns the text size of the expanded title.

### getExpandedTitleTypeface

```
public Typeface getExpandedTitleTypeface()
```

Returns the typeface used for the expanded title.

### getHyphenationFrequency

```
public int getHyphenationFrequency()
```

Gets the hyphenation frequency of the title text, or -1 if not set. Experimental Feature.

### getLineCount

```
public int getLineCount()
```

Gets the current number of lines of the title text. Experimental Feature.

### getLineSpacingAdd

```
public float getLineSpacingAdd()
```

Gets the line spacing addition of the title text, or -1 if not set. Experimental Feature.

### getLineSpacingMultiplier

```
public float getLineSpacingMultiplier()
```

Gets the line spacing multiplier of the title text, or -1 if not set. Experimental Feature.

### getMaxLines

```
public int getMaxLines()
```

Gets the maximum number of lines to display in the expanded state. Experimental Feature.

### getScrimAnimationDuration

```
public long getScrimAnimationDuration()
```

Returns the duration in milliseconds used for scrim visibility animations.

### getScrimVisibleHeightTrigger

```
public int getScrimVisibleHeightTrigger()
```

Returns the amount of visible height in pixels used to define when to trigger a scrim visibility change.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setScrimVisibleHeightTrigger(int)` |   |

### getStatusBarScrim

```
public Drawable getStatusBarScrim()
```

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

ref R.styleable#CollapsingToolbarLayout_statusBarScrim

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

### getSubtitle

```
public CharSequence getSubtitle()
```

Returns the subtitle currently being displayed by this view. If the subtitle is not enabled, then this will return `null`.

ref R.styleable#CollapsingToolbarLayout_subtitle

### getTitle

```
public CharSequence getTitle()
```

Returns the title currently being displayed by this view. If the title is not enabled, then this will return `null`.

ref R.styleable#CollapsingToolbarLayout_title

### getTitleCollapseMode

```
public int getTitleCollapseMode()
```

Returns the current title collapse mode.

ref R.styleable#CollapsingToolbarLayout_titleCollapseMode

### getTitlePositionInterpolator

```
public TimeInterpolator getTitlePositionInterpolator()
```

Returns the interpolator being used to animate the title position from collapsed to expanded and vice versa.

### getTitleTextEllipsize

```
public TruncateAt getTitleTextEllipsize()
```

Get ellipsizing currently applied on the title text.

### isExtraMultilineHeightEnabled

```
public boolean isExtraMultilineHeightEnabled()
```

Gets whether extra height should be added when the title text spans across multiple lines. Experimental Feature.

### isForceApplySystemWindowInsetTop

```
public boolean isForceApplySystemWindowInsetTop()
```

Gets whether the top system window inset should be respected regardless of what the `
layout_height` of the `CollapsingToolbarLayout` is set to. Experimental Feature.

### isRtlTextDirectionHeuristicsEnabled

```
public boolean isRtlTextDirectionHeuristicsEnabled()
```

Gets whether `TextDirectionHeuristics` should be used to determine whether the title text is RTL. Experimental Feature.

### isTitleEnabled

```
public boolean isTitleEnabled()
```

Returns whether this view is currently displaying its own title.

ref R.styleable#CollapsingToolbarLayout_titleEnabled

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitleEnabled(boolean)` |   |

### setCollapsedSubtitleTextAppearance

```
public void setCollapsedSubtitleTextAppearance(int resId)
```

Sets the text color and size for the collapsed subtitle from the specified TextAppearance resource.

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

### setCollapsedSubtitleTextColor

```
public void setCollapsedSubtitleTextColor(int color)
```

Sets the text color of the collapsed subtitle.

| Parameters |
|---|---|
| `int color` | The new text color in ARGB format |

### setCollapsedSubtitleTextColor

```
public void setCollapsedSubtitleTextColor(ColorStateList colors)
```

Sets the text colors of the collapsed subtitle.

| Parameters |
|---|---|
| `ColorStateList colors` | ColorStateList containing the new text colors |

### setCollapsedSubtitleTextSize

```
public void setCollapsedSubtitleTextSize(float textSize)
```

Sets the text size of the collapsed subtitle.

| Parameters |
|---|---|
| `float textSize` | The text size of the collapsed subtitle. |

### setCollapsedSubtitleTypeface

```
public void setCollapsedSubtitleTypeface(Typeface typeface)
```

Set the typeface to use for the collapsed subtitle.

| Parameters |
|---|---|
| `Typeface typeface` | typeface to use, or `null` to use the default. |

### setCollapsedTitleGravity

```
public void setCollapsedTitleGravity(int gravity)
```

Sets the horizontal alignment of the collapsed titles and the vertical gravity that will be used when there is extra space in the collapsed bounds beyond what is required for the title itself.

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

### setCollapsedTitleTextAppearance

```
public void setCollapsedTitleTextAppearance(int resId)
```

Sets the text color and size for the collapsed title from the specified TextAppearance resource.

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

### setCollapsedTitleTextColor

```
public void setCollapsedTitleTextColor(int color)
```

Sets the text color of the collapsed title.

| Parameters |
|---|---|
| `int color` | The new text color in ARGB format |

### setCollapsedTitleTextColor

```
public void setCollapsedTitleTextColor(ColorStateList colors)
```

Sets the text colors of the collapsed title.

| Parameters |
|---|---|
| `ColorStateList colors` | ColorStateList containing the new text colors |

### setCollapsedTitleTextSize

```
public void setCollapsedTitleTextSize(float textSize)
```

Sets the text size of the collapsed title.

| Parameters |
|---|---|
| `float textSize` | The text size of the collapsed title. |

### setCollapsedTitleTypeface

```
public void setCollapsedTitleTypeface(Typeface typeface)
```

Set the typeface to use for the collapsed title.

| Parameters |
|---|---|
| `Typeface typeface` | typeface to use, or `null` to use the default. |

### setContentScrim

```
public void setContentScrim(Drawable drawable)
```

Set the drawable to use for the content scrim from resources. Providing null will disable the scrim functionality.

ref R.styleable#CollapsingToolbarLayout_contentScrim

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

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

### setContentScrimColor

```
public void setContentScrimColor(int color)
```

Set the color to use for the content scrim.

ref R.styleable#CollapsingToolbarLayout_contentScrim

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

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

### setContentScrimResource

```
public void setContentScrimResource(int resId)
```

Set the drawable to use for the content scrim from resources.

ref R.styleable#CollapsingToolbarLayout_contentScrim

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

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

### setExpandedSubtitleColor

```
public void setExpandedSubtitleColor(int color)
```

Sets the text color of the expanded subtitle.

| Parameters |
|---|---|
| `int color` | The new text color in ARGB format |

### setExpandedSubtitleTextAppearance

```
public void setExpandedSubtitleTextAppearance(int resId)
```

Sets the text color and size for the expanded subtitle from the specified TextAppearance resource.

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

### setExpandedSubtitleTextColor

```
public void setExpandedSubtitleTextColor(ColorStateList colors)
```

Sets the text colors of the expanded subtitle.

| Parameters |
|---|---|
| `ColorStateList colors` | ColorStateList containing the new text colors |

### setExpandedSubtitleTextSize

```
public void setExpandedSubtitleTextSize(float textSize)
```

Sets the text size of the expanded subtitle.

| Parameters |
|---|---|
| `float textSize` | The text size of the expanded subtitle. |

### setExpandedSubtitleTypeface

```
public void setExpandedSubtitleTypeface(Typeface typeface)
```

Set the typeface to use for the expanded subtitle.

| Parameters |
|---|---|
| `Typeface typeface` | typeface to use, or `null` to use the default. |

### setExpandedTitleColor

```
public void setExpandedTitleColor(int color)
```

Sets the text color of the expanded title.

| Parameters |
|---|---|
| `int color` | The new text color in ARGB format |

### setExpandedTitleGravity

```
public void setExpandedTitleGravity(int gravity)
```

Sets the horizontal alignment of the expanded titles and the vertical gravity that will be used when there is extra space in the expanded bounds beyond what is required for the title itself.

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

### setExpandedTitleMargin

```
public void setExpandedTitleMargin(int start, int top, int end, int bottom)
```

Sets the expanded title margins.

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

| Parameters |
|---|---|
| `int start` | the starting title margin in pixels |
| `int top` | the top title margin in pixels |
| `int end` | the ending title margin in pixels |
| `int bottom` | the bottom title margin in pixels |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleMarginStart()` |   |
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleMarginTop()` |   |
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleMarginEnd()` |   |
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getExpandedTitleMarginBottom()` |   |

### setExpandedTitleMarginBottom

```
public void setExpandedTitleMarginBottom(int margin)
```

Sets the bottom expanded title margin in pixels.

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

| Parameters |
|---|---|
| `int margin` | the bottom title margin in pixels |

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

### setExpandedTitleMarginEnd

```
public void setExpandedTitleMarginEnd(int margin)
```

Sets the ending expanded title margin in pixels.

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

| Parameters |
|---|---|
| `int margin` | the ending title margin in pixels |

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

### setExpandedTitleMarginStart

```
public void setExpandedTitleMarginStart(int margin)
```

Sets the starting expanded title margin in pixels.

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

| Parameters |
|---|---|
| `int margin` | the starting title margin in pixels |

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

### setExpandedTitleMarginTop

```
public void setExpandedTitleMarginTop(int margin)
```

Sets the top expanded title margin in pixels.

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

| Parameters |
|---|---|
| `int margin` | the top title margin in pixels |

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

### setExpandedTitleSpacing

```
public void setExpandedTitleSpacing(int titleSpacing)
```

Sets the spacing between the expanded title and subtitle.

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

| Parameters |
|---|---|
| `int titleSpacing` | the spacing between the expanded title and subtitle in pixels |

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

### setExpandedTitleTextAppearance

```
public void setExpandedTitleTextAppearance(int resId)
```

Sets the text color and size for the expanded title from the specified TextAppearance resource.

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

### setExpandedTitleTextColor

```
public void setExpandedTitleTextColor(ColorStateList colors)
```

Sets the text colors of the expanded title.

| Parameters |
|---|---|
| `ColorStateList colors` | ColorStateList containing the new text colors |

### setExpandedTitleTextSize

```
public void setExpandedTitleTextSize(float textSize)
```

Sets the text size of the expanded title.

| Parameters |
|---|---|
| `float textSize` | The text size of the expanded title. |

### setExpandedTitleTypeface

```
public void setExpandedTitleTypeface(Typeface typeface)
```

Set the typeface to use for the expanded title.

| Parameters |
|---|---|
| `Typeface typeface` | typeface to use, or `null` to use the default. |

### setExtraMultilineHeightEnabled

```
public void setExtraMultilineHeightEnabled(boolean extraMultilineHeightEnabled)
```

Sets whether extra height should be added when the title text spans across multiple lines. Experimental Feature.

### setForceApplySystemWindowInsetTop

```
public void setForceApplySystemWindowInsetTop(
    boolean forceApplySystemWindowInsetTop
)
```

Sets whether the top system window inset should be respected regardless of what the `
layout_height` of the `CollapsingToolbarLayout` is set to. Experimental Feature.

### setHyphenationFrequency

```
public void setHyphenationFrequency(int hyphenationFrequency)
```

Sets the hyphenation frequency of the title text. See setHyphenationFrequency. Experimental Feature.

### setLineSpacingAdd

```
public void setLineSpacingAdd(float spacingAdd)
```

Sets the line spacing addition of the title text. See setLineSpacing. Experimental Feature.

### setLineSpacingMultiplier

```
public void setLineSpacingMultiplier(float spacingMultiplier)
```

Sets the line spacing multiplier of the title text. See setLineSpacing. Experimental Feature.

### setMaxLines

```
public void setMaxLines(int maxLines)
```

Sets the maximum number of lines to display in the expanded state. Experimental Feature.

### setRtlTextDirectionHeuristicsEnabled

```
public void setRtlTextDirectionHeuristicsEnabled(
    boolean rtlTextDirectionHeuristicsEnabled
)
```

Sets whether `TextDirectionHeuristics` should be used to determine whether the title text is RTL. Experimental Feature.

### setScrimAnimationDuration

```
public void setScrimAnimationDuration(long duration)
```

Set the duration used for scrim visibility animations.

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

| Parameters |
|---|---|
| `long duration` | the duration to use in milliseconds |

### setScrimVisibleHeightTrigger

```
public void setScrimVisibleHeightTrigger(int height)
```

Set the amount of visible height in pixels used to define when to trigger a scrim visibility change.

If the visible height of this view is less than the given value, the scrims will be made visible, otherwise they are hidden.

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

| Parameters |
|---|---|
| `int height` | value in pixels used to define when to trigger a scrim visibility change |

### setScrimsShown

```
public void setScrimsShown(boolean shown)
```

Set whether the content scrim and/or status bar scrim should be shown or not. Any change in the vertical scroll may overwrite this value. Any visibility change will be animated if this view has already been laid out.

| Parameters |
|---|---|
| `boolean shown` | whether the scrims should be shown |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getStatusBarScrim()` |   |
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getContentScrim()` |   |

### setScrimsShown

```
public void setScrimsShown(boolean shown, boolean animate)
```

Set whether the content scrim and/or status bar scrim should be shown or not. Any change in the vertical scroll may overwrite this value.

| Parameters |
|---|---|
| `boolean shown` | whether the scrims should be shown |
| `boolean animate` | whether to animate the visibility change |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getStatusBarScrim()` |   |
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getContentScrim()` |   |

### setStatusBarScrim

```
public void setStatusBarScrim(Drawable drawable)
```

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

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

ref R.styleable#CollapsingToolbarLayout_statusBarScrim

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

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

### setStatusBarScrimColor

```
public void setStatusBarScrimColor(int color)
```

Set the color to use for the status bar scrim.

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

ref R.styleable#CollapsingToolbarLayout_statusBarScrim

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

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

### setStatusBarScrimResource

```
public void setStatusBarScrimResource(int resId)
```

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

ref R.styleable#CollapsingToolbarLayout_statusBarScrim

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

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

### setSubtitle

```
public void setSubtitle(CharSequence subtitle)
```

Sets the subtitle to be displayed by this view, if enabled.

ref R.styleable#CollapsingToolbarLayout_subtitle

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitleEnabled(boolean)` |   |
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getSubtitle()` |   |

### setTitle

```
public void setTitle(CharSequence title)
```

Sets the title to be displayed by this view, if enabled.

ref R.styleable#CollapsingToolbarLayout_title

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitleEnabled(boolean)` |   |
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#getTitle()` |   |

### setTitleCollapseMode

```
public void setTitleCollapseMode(int titleCollapseMode)
```

Sets the title collapse mode which determines the effect used to collapse and expand the title text.

ref R.styleable#CollapsingToolbarLayout_titleCollapseMode

### setTitleEllipsize

```
public void setTitleEllipsize(TruncateAt ellipsize)
```

Set ellipsizing on the title text.

ref R.styleable#CollapsingToolbarLayout_titleTextEllipsize

| Parameters |
|---|---|
| `TruncateAt ellipsize` | type of ellipsis behavior |

### setTitleEnabled

```
public void setTitleEnabled(boolean enabled)
```

Sets whether this view should display its own title.

The title displayed by this view will shrink and grow based on the scroll offset.

ref R.styleable#CollapsingToolbarLayout_titleEnabled

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#setTitle(java.lang.CharSequence)` |   |
| `https://developer.android.com/reference/com/google/android/material/appbar/CollapsingToolbarLayout#isTitleEnabled()` |   |

### setTitlePositionInterpolator

```
public void setTitlePositionInterpolator(TimeInterpolator interpolator)
```

Sets the interpolator to use when animating the title position from collapsed to expanded and vice versa.

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

| Parameters |
|---|---|
| `TimeInterpolator interpolator` | the interpolator to use. |

### setVisibility

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

## Protected methods

### checkLayoutParams

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

### drawChild

```
protected boolean drawChild(Canvas canvas, View child, long drawingTime)
```

### drawableStateChanged

```
protected void drawableStateChanged()
```

### generateDefaultLayoutParams

```
protected CollapsingToolbarLayout.LayoutParams generateDefaultLayoutParams()
```

### generateLayoutParams

```
protected LayoutParams generateLayoutParams(LayoutParams p)
```

### onAttachedToWindow

```
protected void onAttachedToWindow()
```

### onConfigurationChanged

```
protected void onConfigurationChanged(Configuration newConfig)
```

### onDetachedFromWindow

```
protected void onDetachedFromWindow()
```

### onLayout

```
protected void onLayout(boolean changed, int left, int top, int right, int bottom)
```

### onMeasure

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

### onSizeChanged

```
protected void onSizeChanged(int w, int h, int oldw, int oldh)
```

### verifyDrawable

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