CollapsingToolbarLayout

(SESL Variant) 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. 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. 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. 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. 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.

For more information, see the component developer guidance and design guidelines.

Constructors

Link copied to clipboard
constructor(@NonNull context: Context)
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet)
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet, defStyleAttr: Int)

Types

Link copied to clipboard
Link copied to clipboard
Interface that allows for further customization of the provided .
Link copied to clipboard

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
The expanded title will fade out and translate, and the collapsed title will fade in.
Link copied to clipboard
The expanded title will continuously scale and translate to its final collapsed position.
Link copied to clipboard

Functions

Link copied to clipboard
open fun addView(child: View, params: ViewGroup.LayoutParams)
Link copied to clipboard
open fun draw(@NonNull canvas: Canvas)
Link copied to clipboard
Returns the horizontal and vertical alignment for title when collapsed.
Link copied to clipboard
Returns the text size of the collapsed title.
Link copied to clipboard
Returns the typeface used for the collapsed title.
Link copied to clipboard
Returns the horizontal and vertical alignment for title when expanded.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Returns the text size of the expanded title.
Link copied to clipboard
Returns the typeface used for the expanded title.
Link copied to clipboard
Gets the hyphenation frequency of the title text, or -1 if not set.
Link copied to clipboard
Gets the current number of lines of the title text.
Link copied to clipboard
Gets the line spacing addition of the title text, or -1 if not set.
Link copied to clipboard
Gets the line spacing multiplier of the title text, or -1 if not set.
Link copied to clipboard
Gets the maximum number of lines to display in the expanded state.
Link copied to clipboard
Returns the subtitle of this view when expanded.
Link copied to clipboard
Returns the title currently being displayed by this view.
Link copied to clipboard
Returns the interpolator being used to animate the title position from collapsed to expanded and vice versa.
Link copied to clipboard
Get ellipsizing currently applied on the title text.
Link copied to clipboard
Gets whether extra height should be added when the title text spans across multiple lines.
Link copied to clipboard
Gets whether the top system window inset should be respected regardless of what the layout_height of the CollapsingToolbarLayout is set to.
Link copied to clipboard
Gets whether TextDirectionHeuristics should be used to determine whether the title text is RTL.
Link copied to clipboard
Returns whether this view is currently displaying its own title.
Link copied to clipboard
Sets whether to enable or disable the fade effect of the collapsed title.
Link copied to clipboard
Retrieves the custom subtitle view.
Link copied to clipboard
This method differs from getMinimumHeight in that it subtracts the top and bottom margins of the toolbar.
Link copied to clipboard
Returns whether this field uses custom accessibility.
Link copied to clipboard
open fun seslSetCustomSubtitle(view: View)
Sets a custom view to replace the expanded subtitle.
Link copied to clipboard
Sets a custom view to replace the expanded title.
Link copied to clipboard
open fun seslSetSubtitle(@StringRes resId: Int)
open fun seslSetSubtitle(subtitle: CharSequence)
Sets the subtitle of this view.
Link copied to clipboard
open fun seslSetSuggestView(@Nullable appBarModel: AppBarModel<out AppBarView>)
Sets the suggestion view for the AppBarLayout.
Link copied to clipboard
Sets whether to use custom accessibility features.
Link copied to clipboard
open fun setCollapsedTitleGravity(gravity: Int)
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.
Link copied to clipboard
Sets the text color and size for the collapsed title from the specified TextAppearance resource.
Link copied to clipboard
Sets the text colors of the collapsed title.
Sets the text color of the collapsed title.
Link copied to clipboard
open fun setCollapsedTitleTextSize(textSize: Float)
Sets the text size of the collapsed title.
Link copied to clipboard
Set the typeface to use for the collapsed title.
Link copied to clipboard
open fun setContentScrimColor(@ColorInt color: Int)
Set the color to use for the content scrim.
Link copied to clipboard
Set the drawable to use for the content scrim from resources.
Link copied to clipboard
Sets the text color of the expanded title.
Link copied to clipboard
open fun setExpandedTitleGravity(gravity: Int)
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.
Link copied to clipboard
open fun setExpandedTitleMargin(start: Int, top: Int, end: Int, bottom: Int)
Sets the expanded title margins.
Link copied to clipboard
Sets the bottom expanded title margin in pixels.
Link copied to clipboard
open fun setExpandedTitleMarginEnd(margin: Int)
Sets the ending expanded title margin in pixels.
Link copied to clipboard
Sets the starting expanded title margin in pixels.
Link copied to clipboard
open fun setExpandedTitleMarginTop(margin: Int)
Sets the top expanded title margin in pixels.
Link copied to clipboard
Sets the text color and size for the expanded title from the specified TextAppearance resource.
Link copied to clipboard
Sets the text colors of the expanded title.
Link copied to clipboard
open fun setExpandedTitleTextSize(textSize: Float)
Sets the text size of the expanded title.
Link copied to clipboard
Set the typeface to use for the expanded title.
Link copied to clipboard
open fun setExtraMultilineHeightEnabled(extraMultilineHeightEnabled: Boolean)
Sets whether extra height should be added when the title text spans across multiple lines.
Link copied to clipboard
open fun setForceApplySystemWindowInsetTop(forceApplySystemWindowInsetTop: Boolean)
Sets whether the top system window inset should be respected regardless of what the layout_height of the CollapsingToolbarLayout is set to.
Link copied to clipboard
open fun setHyphenationFrequency(hyphenationFrequency: Int)
Sets the hyphenation frequency of the title text.
Link copied to clipboard
Sets the line spacing addition of the title text.
Link copied to clipboard
open fun setLineSpacingMultiplier(@FloatRange(from = 0.0) spacingMultiplier: Float)
Sets the line spacing multiplier of the title text.
Link copied to clipboard
open fun setMaxLines(maxLines: Int)
Sets the maximum number of lines to display in the expanded state.
Link copied to clipboard
open fun setRtlTextDirectionHeuristicsEnabled(rtlTextDirectionHeuristicsEnabled: Boolean)
Sets whether TextDirectionHeuristics should be used to determine whether the title text is RTL.
Link copied to clipboard
open fun setScrimsShown(shown: Boolean)
open fun setScrimsShown(shown: Boolean, animate: Boolean)
Set whether the content scrim and/or status bar scrim should be shown or not.
Link copied to clipboard
Set the color to use for the status bar scrim.
Link copied to clipboard
Set the drawable to use for the status bar scrim from resources.
Link copied to clipboard
open fun setTitle(@Nullable title: CharSequence)
Sets the title to be displayed by this view, if enabled.
Link copied to clipboard
Set ellipsizing on the title text.
Link copied to clipboard
open fun setTitleEnabled(enabled: Boolean)
Sets whether this view should display its own title.
Link copied to clipboard
Sets the interpolator to use when animating the title position from collapsed to expanded and vice versa.
Link copied to clipboard
open fun setVisibility(visibility: Int)