CollapsingToolbarLayout

public class CollapsingToolbarLayout
extends FrameLayout

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ com.google.android.material.appbar.CollapsingToolbarLayout


CollapsingToolbarLayout is a wrapper for Toolbar which implements a collapsing app bar. It is designed to be used as a direct child of a 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 setTitle(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 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 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 CollapsingToolbarLayout.LayoutParams.COLLAPSE_MODE_PARALLAX and 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 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 and design guidelines.

Summary

Nested classes

class CollapsingToolbarLayout.LayoutParams

 

XML attributes

CollapsingToolbarLayout_collapsedTitleGravity  
CollapsingToolbarLayout_collapsedTitleTextAppearance  
CollapsingToolbarLayout_contentScrim  
CollapsingToolbarLayout_expandedTitleGravity  
CollapsingToolbarLayout_expandedTitleMargin  
CollapsingToolbarLayout_expandedTitleMarginBottom  
CollapsingToolbarLayout_expandedTitleMarginEnd  
CollapsingToolbarLayout_expandedTitleMarginStart  
CollapsingToolbarLayout_expandedTitleMarginTop  
CollapsingToolbarLayout_expandedTitleTextAppearance  
CollapsingToolbarLayout_scrimAnimationDuration  
CollapsingToolbarLayout_scrimVisibleHeightTrigger  
CollapsingToolbarLayout_statusBarScrim  
CollapsingToolbarLayout_title  
CollapsingToolbarLayout_titleCollapseMode  
CollapsingToolbarLayout_titleEnabled  
CollapsingToolbarLayout_titlePositionInterpolator  
CollapsingToolbarLayout_titleTextEllipsize  
CollapsingToolbarLayout_toolbarId  

Constants

int TITLE_COLLAPSE_MODE_FADE

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

int TITLE_COLLAPSE_MODE_SCALE

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

Inherited constants

Inherited fields

Public constructors

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

Public methods

void draw(Canvas canvas)
FrameLayout.LayoutParams generateLayoutParams(AttributeSet attrs)
int getCollapsedTitleGravity()

Returns the horizontal and vertical alignment for title when collapsed.

float getCollapsedTitleTextSize()

Returns the text size of the collapsed title.

Typeface getCollapsedTitleTypeface()

Returns the typeface used for the collapsed title.

Drawable getContentScrim()

Returns the drawable which is used for the foreground scrim.

int getExpandedTitleGravity()

Returns the horizontal and vertical alignment for title when expanded.

int getExpandedTitleMarginBottom()
int getExpandedTitleMarginEnd()
int getExpandedTitleMarginStart()
int getExpandedTitleMarginTop()
float getExpandedTitleTextSize()

Returns the text size of the expanded title.

Typeface getExpandedTitleTypeface()

Returns the typeface used for the expanded title.

int getHyphenationFrequency()

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

int getLineCount()

Gets the current number of lines of the title text.

float getLineSpacingAdd()

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

float getLineSpacingMultiplier()

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

int getMaxLines()

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

long getScrimAnimationDuration()

Returns the duration in milliseconds used for scrim visibility animations.

int getScrimVisibleHeightTrigger()

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

Drawable getStatusBarScrim()

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

CharSequence getTitle()

Returns the title currently being displayed by this view.

int getTitleCollapseMode()

Returns the current title collapse mode.

TimeInterpolator getTitlePositionInterpolator()

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

TextUtils.TruncateAt getTitleTextEllipsize()

Get ellipsizing currently applied on the title text.

boolean isExtraMultilineHeightEnabled()

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

boolean isForceApplySystemWindowInsetTop()

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

boolean isRtlTextDirectionHeuristicsEnabled()

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

boolean isTitleEnabled()

Returns whether this view is currently displaying its own title.

void setCollapsedTitleGravity(int gravity)

Sets the horizontal alignment of the collapsed title 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 setCollapsedTitleTextAppearance(int resId)

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

void setCollapsedTitleTextColor(ColorStateList colors)

Sets the text colors of the collapsed title.

void setCollapsedTitleTextColor(int color)

Sets the text color of the collapsed title.

void setCollapsedTitleTextSize(float textSize)

Sets the text size of the collapsed title.

void setCollapsedTitleTypeface(Typeface typeface)

Set the typeface to use for the collapsed title.

void setContentScrim(Drawable drawable)

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

void setContentScrimColor(int color)

Set the color to use for the content scrim.

void setContentScrimResource(int resId)

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

void setExpandedTitleColor(int color)

Sets the text color of the expanded title.

void setExpandedTitleGravity(int gravity)

Sets the horizontal alignment of the expanded title 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 setExpandedTitleMargin(int start, int top, int end, int bottom)

Sets the expanded title margins.

void setExpandedTitleMarginBottom(int margin)

Sets the bottom expanded title margin in pixels.

void setExpandedTitleMarginEnd(int margin)

Sets the ending expanded title margin in pixels.

void setExpandedTitleMarginStart(int margin)

Sets the starting expanded title margin in pixels.

void setExpandedTitleMarginTop(int margin)

Sets the top expanded title margin in pixels.

void setExpandedTitleTextAppearance(int resId)

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

void setExpandedTitleTextColor(ColorStateList colors)

Sets the text colors of the expanded title.

void setExpandedTitleTextSize(float textSize)

Sets the text size of the expanded title.

void setExpandedTitleTypeface(Typeface typeface)

Set the typeface to use for the expanded title.

void setExtraMultilineHeightEnabled(boolean extraMultilineHeightEnabled)

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

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.

void setHyphenationFrequency(int hyphenationFrequency)

Sets the hyphenation frequency of the title text.

void setLineSpacingAdd(float spacingAdd)

Sets the line spacing addition of the title text.

void setLineSpacingMultiplier(float spacingMultiplier)

Sets the line spacing multiplier of the title text.

void setMaxLines(int maxLines)

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

void setRtlTextDirectionHeuristicsEnabled(boolean rtlTextDirectionHeuristicsEnabled)

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

void setScrimAnimationDuration(long duration)

Set the duration used for scrim visibility animations.

void setScrimVisibleHeightTrigger(int height)

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

void setScrimsShown(boolean shown, boolean animate)

Set whether the content scrim and/or status bar scrim should be shown or not.

void setScrimsShown(boolean shown)

Set whether the content scrim and/or status bar scrim should be shown or not.

void setStatusBarScrim(Drawable drawable)

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

void setStatusBarScrimColor(int color)

Set the color to use for the status bar scrim.

void setStatusBarScrimResource(int resId)

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

void setTitle(CharSequence title)

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

void setTitleCollapseMode(int titleCollapseMode)

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

void setTitleEllipsize(TextUtils.TruncateAt ellipsize)

Set ellipsizing on the title text.

void setTitleEnabled(boolean enabled)

Sets whether this view should display its own title.

void setTitlePositionInterpolator(TimeInterpolator interpolator)

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

void setVisibility(int visibility)

Protected methods

boolean checkLayoutParams(ViewGroup.LayoutParams p)
boolean drawChild(Canvas canvas, View child, long drawingTime)
void drawableStateChanged()
CollapsingToolbarLayout.LayoutParams generateDefaultLayoutParams()
FrameLayout.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
void onAttachedToWindow()
void onConfigurationChanged(Configuration newConfig)
void onDetachedFromWindow()
void onLayout(boolean changed, int left, int top, int right, int bottom)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
void onSizeChanged(int w, int h, int oldw, int oldh)
boolean verifyDrawable(Drawable who)

Inherited methods

XML attributes

CollapsingToolbarLayout_collapsedTitleGravity

Related methods:

CollapsingToolbarLayout_collapsedTitleTextAppearance

Related methods:

CollapsingToolbarLayout_contentScrim

Related methods:

CollapsingToolbarLayout_expandedTitleGravity

Related methods:

CollapsingToolbarLayout_expandedTitleMargin

Related methods:

CollapsingToolbarLayout_expandedTitleMarginBottom

Related methods:

CollapsingToolbarLayout_expandedTitleMarginEnd

Related methods:

CollapsingToolbarLayout_expandedTitleMarginStart

Related methods:

CollapsingToolbarLayout_expandedTitleMarginTop

Related methods:

CollapsingToolbarLayout_expandedTitleTextAppearance

Related methods:

CollapsingToolbarLayout_scrimAnimationDuration

Related methods:

CollapsingToolbarLayout_scrimVisibleHeightTrigger

Related methods:

CollapsingToolbarLayout_statusBarScrim

Related methods:

CollapsingToolbarLayout_title

Related methods:

CollapsingToolbarLayout_titleCollapseMode

Related methods:

CollapsingToolbarLayout_titleEnabled

Related methods:

CollapsingToolbarLayout_titlePositionInterpolator

Related methods:

CollapsingToolbarLayout_titleTextEllipsize

Related methods:

CollapsingToolbarLayout_toolbarId

Constants

TITLE_COLLAPSE_MODE_FADE

public static final int TITLE_COLLAPSE_MODE_FADE

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

Constant Value: 1 (0x00000001)

TITLE_COLLAPSE_MODE_SCALE

public static final int TITLE_COLLAPSE_MODE_SCALE

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

Constant Value: 0 (0x00000000)

Public constructors

CollapsingToolbarLayout

public CollapsingToolbarLayout (Context context)

Parameters
context Context

CollapsingToolbarLayout

public CollapsingToolbarLayout (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

CollapsingToolbarLayout

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

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

draw

public void draw (Canvas canvas)

Parameters
canvas Canvas

generateLayoutParams

public FrameLayout.LayoutParams generateLayoutParams (AttributeSet attrs)

Parameters
attrs AttributeSet

Returns
FrameLayout.LayoutParams

getCollapsedTitleGravity

public int getCollapsedTitleGravity ()

Returns the horizontal and vertical alignment for title when collapsed.

Related XML Attributes:

Returns
int

getCollapsedTitleTextSize

public float getCollapsedTitleTextSize ()

Returns the text size of the collapsed title.

Returns
float

getCollapsedTitleTypeface

public Typeface getCollapsedTitleTypeface ()

Returns the typeface used for the collapsed title.

Returns
Typeface

getContentScrim

public Drawable getContentScrim ()

Returns the drawable which is used for the foreground scrim.

Related XML Attributes:

Returns
Drawable

getExpandedTitleGravity

public int getExpandedTitleGravity ()

Returns the horizontal and vertical alignment for title when expanded.

Related XML Attributes:

Returns
int

getExpandedTitleMarginBottom

public int getExpandedTitleMarginBottom ()

Related XML Attributes:

Returns
int the bottom expanded title margin in pixels

getExpandedTitleMarginEnd

public int getExpandedTitleMarginEnd ()

Related XML Attributes:

Returns
int the ending expanded title margin in pixels

getExpandedTitleMarginStart

public int getExpandedTitleMarginStart ()

Related XML Attributes:

Returns
int the starting expanded title margin in pixels

getExpandedTitleMarginTop

public int getExpandedTitleMarginTop ()

Related XML Attributes:

Returns
int the top expanded title margin in pixels

getExpandedTitleTextSize

public float getExpandedTitleTextSize ()

Returns the text size of the expanded title.

Returns
float

getExpandedTitleTypeface

public Typeface getExpandedTitleTypeface ()

Returns the typeface used for the expanded title.

Returns
Typeface

getHyphenationFrequency

public int getHyphenationFrequency ()

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

Returns
int

getLineCount

public int getLineCount ()

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

Returns
int

getLineSpacingAdd

public float getLineSpacingAdd ()

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

Returns
float

getLineSpacingMultiplier

public float getLineSpacingMultiplier ()

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

Returns
float

getMaxLines

public int getMaxLines ()

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

Returns
int

getScrimAnimationDuration

public long getScrimAnimationDuration ()

Returns the duration in milliseconds used for scrim visibility animations.

Returns
long

getScrimVisibleHeightTrigger

public int getScrimVisibleHeightTrigger ()

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

Returns
int

getStatusBarScrim

public Drawable getStatusBarScrim ()

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

Related XML Attributes:

Returns
Drawable

getTitle

public CharSequence getTitle ()

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

Related XML Attributes:

Returns
CharSequence

getTitleCollapseMode

public int getTitleCollapseMode ()

Returns the current title collapse mode.

Related XML Attributes:

Returns
int

getTitlePositionInterpolator

public TimeInterpolator getTitlePositionInterpolator ()

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

Returns
TimeInterpolator

getTitleTextEllipsize

public TextUtils.TruncateAt getTitleTextEllipsize ()

Get ellipsizing currently applied on the title text.

Returns
TextUtils.TruncateAt

isExtraMultilineHeightEnabled

public boolean isExtraMultilineHeightEnabled ()

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

Returns
boolean

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.

Returns
boolean

isRtlTextDirectionHeuristicsEnabled

public boolean isRtlTextDirectionHeuristicsEnabled ()

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

Returns
boolean

isTitleEnabled

public boolean isTitleEnabled ()

Returns whether this view is currently displaying its own title.

Related XML Attributes:

Returns
boolean

setCollapsedTitleGravity

public void setCollapsedTitleGravity (int gravity)

Sets the horizontal alignment of the collapsed title 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.

Related XML Attributes:

Parameters
gravity int

setCollapsedTitleTextAppearance

public void setCollapsedTitleTextAppearance (int resId)

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

Related XML Attributes:

Parameters
resId int

setCollapsedTitleTextColor

public void setCollapsedTitleTextColor (ColorStateList colors)

Sets the text colors of the collapsed title.

Parameters
colors ColorStateList: ColorStateList containing the new text colors

setCollapsedTitleTextColor

public void setCollapsedTitleTextColor (int color)

Sets the text color of the collapsed title.

Parameters
color int: The new text color in ARGB format

setCollapsedTitleTextSize

public void setCollapsedTitleTextSize (float textSize)

Sets the text size of the collapsed title.

Parameters
textSize float: 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.

Related XML Attributes:

Parameters
drawable Drawable: the drawable to display

See also:

setContentScrimColor

public void setContentScrimColor (int color)

Set the color to use for the content scrim.

Related XML Attributes:

Parameters
color int: the color to display

See also:

setContentScrimResource

public void setContentScrimResource (int resId)

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

Related XML Attributes:

Parameters
resId int: drawable resource id

See also:

setExpandedTitleColor

public void setExpandedTitleColor (int color)

Sets the text color of the expanded title.

Parameters
color int: The new text color in ARGB format

setExpandedTitleGravity

public void setExpandedTitleGravity (int gravity)

Sets the horizontal alignment of the expanded title 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.

Related XML Attributes:

Parameters
gravity int

setExpandedTitleMargin

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

Sets the expanded title margins.

Related XML Attributes:

Parameters
start int: the starting title margin in pixels

top int: the top title margin in pixels

end int: the ending title margin in pixels

bottom int: the bottom title margin in pixels

setExpandedTitleMarginBottom

public void setExpandedTitleMarginBottom (int margin)

Sets the bottom expanded title margin in pixels.

Related XML Attributes:

Parameters
margin int: the bottom title margin in pixels

setExpandedTitleMarginEnd

public void setExpandedTitleMarginEnd (int margin)

Sets the ending expanded title margin in pixels.

Related XML Attributes:

Parameters
margin int: the ending title margin in pixels

setExpandedTitleMarginStart

public void setExpandedTitleMarginStart (int margin)

Sets the starting expanded title margin in pixels.

Related XML Attributes:

Parameters
margin int: the starting title margin in pixels

setExpandedTitleMarginTop

public void setExpandedTitleMarginTop (int margin)

Sets the top expanded title margin in pixels.

Related XML Attributes:

Parameters
margin int: the top title margin in pixels

setExpandedTitleTextAppearance

public void setExpandedTitleTextAppearance (int resId)

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

Related XML Attributes:

Parameters
resId int

setExpandedTitleTextColor

public void setExpandedTitleTextColor (ColorStateList colors)

Sets the text colors of the expanded title.

Parameters
colors ColorStateList: ColorStateList containing the new text colors

setExpandedTitleTextSize

public void setExpandedTitleTextSize (float textSize)

Sets the text size of the expanded title.

Parameters
textSize float: 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.

Parameters
extraMultilineHeightEnabled boolean

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.

Parameters
forceApplySystemWindowInsetTop boolean

setHyphenationFrequency

public void setHyphenationFrequency (int hyphenationFrequency)

Sets the hyphenation frequency of the title text. See TextView.setHyphenationFrequency(int). Experimental Feature.

Parameters
hyphenationFrequency int

setLineSpacingAdd

public void setLineSpacingAdd (float spacingAdd)

Sets the line spacing addition of the title text. See TextView.setLineSpacing(float, float). Experimental Feature.

Parameters
spacingAdd float

setLineSpacingMultiplier

public void setLineSpacingMultiplier (float spacingMultiplier)

Sets the line spacing multiplier of the title text. See TextView.setLineSpacing(float, float). Experimental Feature.

Parameters
spacingMultiplier float

setMaxLines

public void setMaxLines (int maxLines)

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

Parameters
maxLines int

setRtlTextDirectionHeuristicsEnabled

public void setRtlTextDirectionHeuristicsEnabled (boolean rtlTextDirectionHeuristicsEnabled)

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

Parameters
rtlTextDirectionHeuristicsEnabled boolean

setScrimAnimationDuration

public void setScrimAnimationDuration (long duration)

Set the duration used for scrim visibility animations.

Related XML Attributes:

Parameters
duration long: 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.

Related XML Attributes:

Parameters
height int: value in pixels used to define when to trigger a scrim visibility change

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
shown boolean: whether the scrims should be shown

animate boolean: whether to animate the 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
shown boolean: whether the scrims should be shown

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.

Related XML Attributes:

Parameters
drawable Drawable: the drawable to display

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.

Related XML Attributes:

Parameters
color int: the color to display

setStatusBarScrimResource

public void setStatusBarScrimResource (int resId)

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

Related XML Attributes:

Parameters
resId int: drawable resource id

setTitle

public void setTitle (CharSequence title)

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

Related XML Attributes:

Parameters
title CharSequence

setTitleCollapseMode

public void setTitleCollapseMode (int titleCollapseMode)

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

Related XML Attributes:

Parameters
titleCollapseMode int

setTitleEllipsize

public void setTitleEllipsize (TextUtils.TruncateAt ellipsize)

Set ellipsizing on the title text.

Related XML Attributes:

Parameters
ellipsize TextUtils.TruncateAt: 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.

Related XML Attributes:

Parameters
enabled boolean

setTitlePositionInterpolator

public void setTitlePositionInterpolator (TimeInterpolator interpolator)

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

Related XML Attributes:

Parameters
interpolator TimeInterpolator: the interpolator to use.

setVisibility

public void setVisibility (int visibility)

Parameters
visibility int

Protected methods

checkLayoutParams

protected boolean checkLayoutParams (ViewGroup.LayoutParams p)

Parameters
p ViewGroup.LayoutParams

Returns
boolean

drawChild

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

Parameters
canvas Canvas

child View

drawingTime long

Returns
boolean

drawableStateChanged

protected void drawableStateChanged ()

generateDefaultLayoutParams

protected CollapsingToolbarLayout.LayoutParams generateDefaultLayoutParams ()

Returns
CollapsingToolbarLayout.LayoutParams

generateLayoutParams

protected FrameLayout.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)

Parameters
p ViewGroup.LayoutParams

Returns
FrameLayout.LayoutParams

onAttachedToWindow

protected void onAttachedToWindow ()

onConfigurationChanged

protected void onConfigurationChanged (Configuration newConfig)

Parameters
newConfig Configuration

onDetachedFromWindow

protected void onDetachedFromWindow ()

onLayout

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

Parameters
changed boolean

left int

top int

right int

bottom int

onMeasure

protected void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
widthMeasureSpec int

heightMeasureSpec int

onSizeChanged

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

Parameters
w int

h int

oldw int

oldh int

verifyDrawable

protected boolean verifyDrawable (Drawable who)

Parameters
who Drawable

Returns
boolean