Most visited

Recently visited

CollapsingToolbarLayout

public class CollapsingToolbarLayout
extends FrameLayout

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.support.design.widget.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 show 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 COLLAPSE_MODE_PARALLAX and 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 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.

Summary

Nested classes

class CollapsingToolbarLayout.LayoutParams

 

XML attributes

android.support.design:collapsedTitleGravity Specifies how the title should be positioned when collapsed. 
android.support.design:collapsedTitleTextAppearance The text appearance of the CollapsingToolbarLayouts title when it is fully 'collapsed'

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name". 

android.support.design:contentScrim The drawable to use as a scrim on top of the CollapsingToolbarLayouts content when it has been scrolled sufficiently off screen. 
android.support.design:expandedTitleGravity Specifies how the title should be positioned when expanded. 
android.support.design:expandedTitleMargin Specifies extra space on the start, top, end and bottom sides of the the expanded title text. 
android.support.design:expandedTitleMarginBottom Specifies extra space on the bottom side of the the expanded title text. 
android.support.design:expandedTitleMarginEnd Specifies extra space on the end side of the the expanded title text. 
android.support.design:expandedTitleMarginStart Specifies extra space on the start side of the the expanded title text. 
android.support.design:expandedTitleMarginTop Specifies extra space on the top side of the the expanded title text. 
android.support.design:expandedTitleTextAppearance The text appearance of the CollapsingToolbarLayout's title when it is fully 'expanded'

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name". 

android.support.design:scrimAnimationDuration Specifies the duration used for scrim visibility animations. 
android.support.design:scrimVisibleHeightTrigger Specifies the amount of visible height in pixels used to define when to trigger a scrim visibility change. 
android.support.design:statusBarScrim The drawable to use as a scrim for the status bar content when the CollapsingToolbarLayout has been scrolled sufficiently off screen. 
android.support.design:title The title to show when titleEnabled is set to true. 
android.support.design:titleEnabled Whether the CollapsingToolbarLayout should draw its own shrinking/growing title. 
android.support.design:toolbarId The id of the primary Toolbar child that you wish to use for the purpose of collapsing. 

Inherited XML attributes

From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View

Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

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

Public methods

void draw(Canvas canvas)

Manually render this view (and all of its children) to the given Canvas.

FrameLayout.LayoutParams generateLayoutParams(AttributeSet attrs)

Returns a new set of layout parameters based on the supplied attributes set.

int getCollapsedTitleGravity()

Returns the horizontal and vertical alignment for title when collapsed.

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()
Typeface getExpandedTitleTypeface()

Returns the typeface used for the expanded title.

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.

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(int color)

Sets the text color 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 setExpandedTitleTypeface(Typeface typeface)

Set the typeface to use for the expanded title.

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 content scrim from resources.

void setTitle(CharSequence title)

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

void setTitleEnabled(boolean enabled)

Sets whether this view should display its own title.

void setVisibility(int visibility)

Set the enabled state of this view.

Protected methods

boolean checkLayoutParams(ViewGroup.LayoutParams p)
boolean drawChild(Canvas canvas, View child, long drawingTime)

Draw one child of this View Group.

void drawableStateChanged()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

CollapsingToolbarLayout.LayoutParams generateDefaultLayoutParams()

Returns a set of layout parameters with a width of MATCH_PARENT, and a height of MATCH_PARENT.

FrameLayout.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)

Returns a safe set of layout parameters based on the supplied layout params.

void onAttachedToWindow()

This is called when the view is attached to a window.

void onDetachedFromWindow()

This is called when the view is detached from a window.

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

Called from layout when this view should assign a size and position to each of its children.

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

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

This is called during layout when the size of this view has changed.

boolean verifyDrawable(Drawable who)

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.

Inherited methods

From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

XML attributes

android.support.design:collapsedTitleGravity

Specifies how the title should be positioned when collapsed.

Must be one or more (separated by '|') of the following constant values.

ConstantValueDescription
bottom50Push title to the bottom of its container, not changing its size.
center11Place the title in the center of its container in both the vertical and horizontal axis, not changing its size.
center_horizontal1Place title in the horizontal center of its container, not changing its size.
center_vertical10Place title in the vertical center of its container, not changing its size.
end800005Push title to the end of its container, not changing its size.
fill_vertical70Grow the vertical size of the title if needed so it completely fills its container.
left3Push title to the left of its container, not changing its size.
right5Push title to the right of its container, not changing its size.
start800003Push title to the beginning of its container, not changing its size.
top30Push title to the top of its container, not changing its size.

Related methods:

android.support.design:collapsedTitleTextAppearance

The text appearance of the CollapsingToolbarLayouts title when it is fully 'collapsed'

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

Related methods:

android.support.design:contentScrim

The drawable to use as a scrim on top of the CollapsingToolbarLayouts content when it has been scrolled sufficiently off screen.

May be a color value, in the form of "#rgb", "#argb", "#rrggbb#aarrggbb".

Related methods:

android.support.design:expandedTitleGravity

Specifies how the title should be positioned when expanded.

Must be one or more (separated by '|') of the following constant values.

ConstantValueDescription
bottom50Push title to the bottom of its container, not changing its size.
center11Place the title in the center of its container in both the vertical and horizontal axis, not changing its size.
center_horizontal1Place title in the horizontal center of its container, not changing its size.
center_vertical10Place title in the vertical center of its container, not changing its size.
end800005Push title to the end of its container, not changing its size.
fill_vertical70Grow the vertical size of the title if needed so it completely fills its container.
left3Push title to the left of its container, not changing its size.
right5Push title to the right of its container, not changing its size.
start800003Push title to the beginning of its container, not changing its size.
top30Push title to the top of its container, not changing its size.

Related methods:

android.support.design:expandedTitleMargin

Specifies extra space on the start, top, end and bottom sides of the the expanded title text. Margin values should be positive.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

Related methods:

android.support.design:expandedTitleMarginBottom

Specifies extra space on the bottom side of the the expanded title text. Margin values should be positive.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

Related methods:

android.support.design:expandedTitleMarginEnd

Specifies extra space on the end side of the the expanded title text. Margin values should be positive.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

Related methods:

android.support.design:expandedTitleMarginStart

Specifies extra space on the start side of the the expanded title text. Margin values should be positive.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

Related methods:

android.support.design:expandedTitleMarginTop

Specifies extra space on the top side of the the expanded title text. Margin values should be positive.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

Related methods:

android.support.design:expandedTitleTextAppearance

The text appearance of the CollapsingToolbarLayout's title when it is fully 'expanded'

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

Related methods:

android.support.design:scrimAnimationDuration

Specifies the duration used for scrim visibility animations.

May be an integer value, such as "100".

Related methods:

android.support.design:scrimVisibleHeightTrigger

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

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

Related methods:

android.support.design:statusBarScrim

The drawable to use as a scrim for the status bar content when the CollapsingToolbarLayout has been scrolled sufficiently off screen. Only works on Lollipop with the correct setup.

May be a color value, in the form of "#rgb", "#argb", "#rrggbb#aarrggbb".

Related methods:

android.support.design:title

The title to show when titleEnabled is set to true.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

May be an integer value, such as "100".

May be a boolean value, such as "true" or "false".

May be a color value, in the form of "#rgb", "#argb", "#rrggbb#aarrggbb".

May be a floating point value, such as "1.2".

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

May be a fractional value, which is a floating point number appended with either % or %p, such as "14.5%". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.

Related methods:

android.support.design:titleEnabled

Whether the CollapsingToolbarLayout should draw its own shrinking/growing title.

May be a boolean value, such as "true" or "false".

Related methods:

android.support.design:toolbarId

The id of the primary Toolbar child that you wish to use for the purpose of collapsing. This Toolbar descendant view does not need to be a direct child of the layout. If you do not set this, the first direct Toolbar child found will be used.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

Public constructors

CollapsingToolbarLayout

CollapsingToolbarLayout (Context context)

Parameters
context Context

CollapsingToolbarLayout

CollapsingToolbarLayout (Context context, 
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

CollapsingToolbarLayout

CollapsingToolbarLayout (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context
attrs AttributeSet
defStyleAttr int

Public methods

draw

void draw (Canvas canvas)

Manually render this view (and all of its children) to the given Canvas. The view must have already done a full layout before this function is called. When implementing a view, implement onDraw(android.graphics.Canvas) instead of overriding this method. If you do need to override this method, call the superclass version.

Parameters
canvas Canvas: The Canvas to which the View is rendered.

generateLayoutParams

FrameLayout.LayoutParams generateLayoutParams (AttributeSet attrs)

Returns a new set of layout parameters based on the supplied attributes set.

Parameters
attrs AttributeSet: the attributes to build the layout parameters from
Returns
FrameLayout.LayoutParams an instance of ViewGroup.LayoutParams or one of its descendants

getCollapsedTitleGravity

int getCollapsedTitleGravity ()

Returns the horizontal and vertical alignment for title when collapsed.

Related XML Attributes:

Returns
int

getCollapsedTitleTypeface

Typeface getCollapsedTitleTypeface ()

Returns the typeface used for the collapsed title.

Returns
Typeface

getContentScrim

Drawable getContentScrim ()

Returns the drawable which is used for the foreground scrim.

Related XML Attributes:

Returns
Drawable

See also:

getExpandedTitleGravity

int getExpandedTitleGravity ()

Returns the horizontal and vertical alignment for title when expanded.

Related XML Attributes:

Returns
int

getExpandedTitleMarginBottom

int getExpandedTitleMarginBottom ()

Related XML Attributes:

Returns
int the bottom expanded title margin in pixels

See also:

getExpandedTitleMarginEnd

int getExpandedTitleMarginEnd ()

Related XML Attributes:

Returns
int the ending expanded title margin in pixels

See also:

getExpandedTitleMarginStart

int getExpandedTitleMarginStart ()

Related XML Attributes:

Returns
int the starting expanded title margin in pixels

See also:

getExpandedTitleMarginTop

int getExpandedTitleMarginTop ()

Related XML Attributes:

Returns
int the top expanded title margin in pixels

See also:

getExpandedTitleTypeface

Typeface getExpandedTitleTypeface ()

Returns the typeface used for the expanded title.

Returns
Typeface

getScrimAnimationDuration

long getScrimAnimationDuration ()

Returns the duration in milliseconds used for scrim visibility animations.

Returns
long

getScrimVisibleHeightTrigger

int getScrimVisibleHeightTrigger ()

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

Returns
int

See also:

getStatusBarScrim

Drawable getStatusBarScrim ()

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

Related XML Attributes:

Returns
Drawable

See also:

getTitle

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

isTitleEnabled

boolean isTitleEnabled ()

Returns whether this view is currently displaying its own title.

Related XML Attributes:

Returns
boolean

See also:

setCollapsedTitleGravity

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

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

void setCollapsedTitleTextColor (int color)

Sets the text color of the collapsed title.

Parameters
color int: The new text color in ARGB format

setCollapsedTitleTypeface

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

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

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

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

void setExpandedTitleColor (int color)

Sets the text color of the expanded title.

Parameters
color int: The new text color in ARGB format

setExpandedTitleGravity

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

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

See also:

setExpandedTitleMarginBottom

void setExpandedTitleMarginBottom (int margin)

Sets the bottom expanded title margin in pixels.

Related XML Attributes:

Parameters
margin int: the bottom title margin in pixels

See also:

setExpandedTitleMarginEnd

void setExpandedTitleMarginEnd (int margin)

Sets the ending expanded title margin in pixels.

Related XML Attributes:

Parameters
margin int: the ending title margin in pixels

See also:

setExpandedTitleMarginStart

void setExpandedTitleMarginStart (int margin)

Sets the starting expanded title margin in pixels.

Related XML Attributes:

Parameters
margin int: the starting title margin in pixels

See also:

setExpandedTitleMarginTop

void setExpandedTitleMarginTop (int margin)

Sets the top expanded title margin in pixels.

Related XML Attributes:

Parameters
margin int: the top title margin in pixels

See also:

setExpandedTitleTextAppearance

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

setExpandedTitleTypeface

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.

setScrimAnimationDuration

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

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

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

See also:

setScrimsShown

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

See also:

setStatusBarScrim

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

See also:

setStatusBarScrimColor

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

See also:

setStatusBarScrimResource

void setStatusBarScrimResource (int resId)

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

Related XML Attributes:

Parameters
resId int: drawable resource id

See also:

setTitle

void setTitle (CharSequence title)

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

Related XML Attributes:

Parameters
title CharSequence

See also:

setTitleEnabled

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

See also:

setVisibility

void setVisibility (int visibility)

Set the enabled state of this view.

Parameters
visibility int: One of VISIBLE, INVISIBLE, or GONE.

Protected methods

checkLayoutParams

boolean checkLayoutParams (ViewGroup.LayoutParams p)

Parameters
p ViewGroup.LayoutParams
Returns
boolean

drawChild

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

Draw one child of this View Group. This method is responsible for getting the canvas in the right state. This includes clipping, translating so that the child's scrolled origin is at 0, 0, and applying any animation transformations.

Parameters
canvas Canvas: The canvas on which to draw the child
child View: Who to draw
drawingTime long: The time at which draw is occurring
Returns
boolean True if an invalidate() was issued

drawableStateChanged

void drawableStateChanged ()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

If the View has a StateListAnimator, it will also be called to run necessary state change animations.

Be sure to call through to the superclass when overriding this function.

generateDefaultLayoutParams

CollapsingToolbarLayout.LayoutParams generateDefaultLayoutParams ()

Returns a set of layout parameters with a width of MATCH_PARENT, and a height of MATCH_PARENT.

Returns
CollapsingToolbarLayout.LayoutParams a set of default layout parameters or null

generateLayoutParams

FrameLayout.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)

Returns a safe set of layout parameters based on the supplied layout params. When a ViewGroup is passed a View whose layout params do not pass the test of checkLayoutParams(android.view.ViewGroup.LayoutParams), this method is invoked. This method should return a new set of layout params suitable for this ViewGroup, possibly by copying the appropriate attributes from the specified set of layout params.

Parameters
p ViewGroup.LayoutParams: The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
Returns
FrameLayout.LayoutParams an instance of ViewGroup.LayoutParams or one of its descendants

onAttachedToWindow

void onAttachedToWindow ()

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).

onDetachedFromWindow

void onDetachedFromWindow ()

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.

onLayout

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

Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.

Parameters
changed boolean: This is a new size or position for this view
left int: Left position, relative to parent
top int: Top position, relative to parent
right int: Right position, relative to parent
bottom int: Bottom position, relative to parent

onMeasure

void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec int: horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec int: vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.

onSizeChanged

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

This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.

Parameters
w int: Current width of this view.
h int: Current height of this view.
oldw int: Old width of this view.
oldh int: Old height of this view.

verifyDrawable

boolean verifyDrawable (Drawable who)

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.

Be sure to call through to the super class when overriding this function.

Parameters
who Drawable: The Drawable to verify. Return true if it is one you are displaying, else return the result of calling through to the super class.
Returns
boolean boolean If true than the Drawable is being displayed in the view; else false and it is not allowed to animate.

Hooray!