Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

Toolbar

open class Toolbar : ViewGroup
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ androidx.appcompat.widget.Toolbar

A standard toolbar for use within application content.

A Toolbar is a generalization of action bars for use within application layouts. While an action bar is traditionally part of an Activity's opaque window decor controlled by the framework, a Toolbar may be placed at any arbitrary level of nesting within a view hierarchy. An application may choose to designate a Toolbar as the action bar for an Activity using the setSupportActionBar() method.

Toolbar supports a more focused feature set than ActionBar. From start to end, a toolbar may contain a combination of the following optional elements:

  • A navigation button. This may be an Up arrow, navigation menu toggle, close, collapse, done or another glyph of the app's choosing. This button should always be used to access other navigational destinations within the container of the Toolbar and its signified content or otherwise leave the current context signified by the Toolbar. The navigation button is vertically aligned within the Toolbar's minimum height, if set.
  • A branded logo image. This may extend to the height of the bar and can be arbitrarily wide.
  • A title and subtitle. The title should be a signpost for the Toolbar's current position in the navigation hierarchy and the content contained there. The subtitle, if present should indicate any extended information about the current content. If an app uses a logo image it should strongly consider omitting a title and subtitle.
  • One or more custom views. The application may add arbitrary child views to the Toolbar. They will appear at this position within the layout. If a child view's LayoutParams indicates a Gravity value of CENTER_HORIZONTAL the view will attempt to center within the available space remaining in the Toolbar after all other elements have been measured.
  • An action menu. The menu of actions will pin to the end of the Toolbar offering a few frequent, important or typical actions along with an optional overflow menu for additional actions. Action buttons are vertically aligned within the Toolbar's minimum height, if set.

In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.

androidx.appcompat.R.attr#buttonGravity androidx.appcompat.R.attr#collapseContentDescription androidx.appcompat.R.attr#collapseIcon androidx.appcompat.R.attr#contentInsetEnd androidx.appcompat.R.attr#contentInsetLeft androidx.appcompat.R.attr#contentInsetRight androidx.appcompat.R.attr#contentInsetStart androidx.appcompat.R.attr#contentInsetStartWithNavigation androidx.appcompat.R.attr#contentInsetEndWithActions android.R.attr#gravity androidx.appcompat.R.attr#logo androidx.appcompat.R.attr#logoDescription androidx.appcompat.R.attr#maxButtonHeight androidx.appcompat.R.attr#navigationContentDescription androidx.appcompat.R.attr#navigationIcon androidx.appcompat.R.attr#popupTheme androidx.appcompat.R.attr#subtitle androidx.appcompat.R.attr#subtitleTextAppearance androidx.appcompat.R.attr#subtitleTextColor androidx.appcompat.R.attr#title androidx.appcompat.R.attr#titleMargin androidx.appcompat.R.attr#titleMarginBottom androidx.appcompat.R.attr#titleMarginEnd androidx.appcompat.R.attr#titleMarginStart androidx.appcompat.R.attr#titleMarginTop androidx.appcompat.R.attr#titleTextAppearance androidx.appcompat.R.attr#titleTextColor androidx.appcompat.R.attr#menu

Summary

Nested classes

open

Layout information for child views of Toolbars.

abstract

Interface responsible for receiving menu item click events if the items themselves do not have individual item click listeners.

open

Public constructors

<init>(context: Context!)

<init>(context: Context!, @Nullable attrs: AttributeSet?)

<init>(context: Context!, @Nullable attrs: AttributeSet?, defStyleAttr: Int)

Public methods

open Unit

Collapse a currently expanded action view.

open Unit

Dismiss all currently showing popup menus, including overflow or submenus.

open Toolbar.LayoutParams!

open CharSequence?

Retrieve the currently configured content description for the collapse button view.

open Drawable?

Return the current drawable used as the collapse icon.

open Int

Gets the ending content inset for this toolbar.

open Int

Gets the end content inset to use when action buttons are present.

open Int

Gets the left content inset for this toolbar.

open Int

Gets the right content inset for this toolbar.

open Int

Gets the starting content inset for this toolbar.

open Int

Gets the start content inset to use when a navigation button is present.

open Int

Gets the content inset that will be used on the ending side of the bar in the current toolbar configuration.

open Int

Gets the content inset that will be used on the left side of the bar in the current toolbar configuration.

open Int

Gets the content inset that will be used on the right side of the bar in the current toolbar configuration.

open Int

Gets the content inset that will be used on the starting side of the bar in the current toolbar configuration.

open Drawable!

Return the current logo drawable.

open CharSequence!

Return the description of the toolbar's logo.

open Menu!

Return the Menu shown in the toolbar.

open CharSequence?

Retrieve the currently configured content description for the navigation button view.

open Drawable?

Return the current drawable used as the navigation icon.

open Drawable?

Return the current drawable used as the overflow icon.

open Int

open CharSequence!

Return the subtitle of this toolbar.

open CharSequence!

Returns the title of this toolbar.

open Int

open Int

open Int

open Int

open Boolean

Check whether this Toolbar is currently hosting an expanded action view.

open Boolean

Hide the overflow items from the associated menu.

open Unit
inflateMenu(@MenuRes resId: Int)

Inflate a menu resource into this toolbar.

open Boolean

Check whether the overflow menu is currently showing.

open Boolean

open Unit
onRtlPropertiesChanged(layoutDirection: Int)

open Boolean

open Unit

Set a content description for the collapse button if one is present.

open Unit

Set a content description for the collapse button if one is present.

open Unit
setCollapseIcon(@DrawableRes resId: Int)

Set the icon to use for the toolbar's collapse button.

open Unit
setCollapseIcon(@Nullable icon: Drawable?)

Set the icon to use for the toolbar's collapse button.

open Unit
setContentInsetEndWithActions(insetEndWithActions: Int)

Sets the start content inset to use when action buttons are present.

open Unit
setContentInsetStartWithNavigation(insetStartWithNavigation: Int)

Sets the start content inset to use when a navigation button is present.

open Unit
setContentInsetsAbsolute(contentInsetLeft: Int, contentInsetRight: Int)

Sets the content insets for this toolbar.

open Unit
setContentInsetsRelative(contentInsetStart: Int, contentInsetEnd: Int)

Sets the content insets for this toolbar relative to layout direction.

open Unit
setLogo(@DrawableRes resId: Int)

Set a logo drawable from a resource id.

open Unit
setLogo(drawable: Drawable!)

Set a logo drawable.

open Unit
setLogoDescription(@StringRes resId: Int)

Set a description of the toolbar's logo.

open Unit

Set a description of the toolbar's logo.

open Unit

Set a content description for the navigation button if one is present.

open Unit

Set a content description for the navigation button if one is present.

open Unit
setNavigationIcon(@DrawableRes resId: Int)

Set the icon to use for the toolbar's navigation button.

open Unit
setNavigationIcon(@Nullable icon: Drawable?)

Set the icon to use for the toolbar's navigation button.

open Unit

Set a listener to respond to navigation events.

open Unit

Set a listener to respond to menu item click events.

open Unit
setOverflowIcon(@Nullable icon: Drawable?)

Set the icon to use for the overflow button.

open Unit
setPopupTheme(@StyleRes resId: Int)

Specifies the theme to use when inflating popup menus.

open Unit
setSubtitle(@StringRes resId: Int)

Set the subtitle of this toolbar.

open Unit

Set the subtitle of this toolbar.

open Unit
setSubtitleTextAppearance(context: Context!, @StyleRes resId: Int)

Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.

open Unit

Sets the text color of the subtitle, if present.

open Unit

Sets the text color of the subtitle, if present.

open Unit
setTitle(@StringRes resId: Int)

Set the title of this toolbar.

open Unit

Set the title of this toolbar.

open Unit
setTitleMargin(start: Int, top: Int, end: Int, bottom: Int)

Sets the title margin.

open Unit

Sets the bottom title margin in pixels.

open Unit

Sets the ending title margin in pixels.

open Unit

Sets the starting title margin in pixels.

open Unit

Sets the top title margin in pixels.

open Unit
setTitleTextAppearance(context: Context!, @StyleRes resId: Int)

Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.

open Unit

Sets the text color of the title, if present.

open Unit

Sets the text color of the title, if present.

open Boolean

Show the overflow items from the associated menu.

Protected methods

open Boolean

open Toolbar.LayoutParams!

open Toolbar.LayoutParams!

open Unit

open Unit
onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int)

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

open Unit

open Parcelable!

Extension functions

From androidx.navigation.ui.androidx.appcompat.widget.Toolbar
Unit
Toolbar.setupWithNavController(navController: NavController, drawerLayout: DrawerLayout?)

Sets up a Toolbar for use with a NavController.

Unit
Toolbar.setupWithNavController(navController: NavController, configuration: AppBarConfiguration = AppBarConfiguration(navController.graph))

Sets up a Toolbar for use with a NavController.

Public constructors

<init>

Toolbar(context: Context!)

<init>

Toolbar(context: Context!, @Nullable attrs: AttributeSet?)

<init>

Toolbar(context: Context!, @Nullable attrs: AttributeSet?, defStyleAttr: Int)

Public methods

collapseActionView

open fun collapseActionView(): Unit

Collapse a currently expanded action view. If this Toolbar does not have an expanded action view this method has no effect.

An action view may be expanded either directly from the MenuItem it belongs to or by user action.

dismissPopupMenus

open fun dismissPopupMenus(): Unit

Dismiss all currently showing popup menus, including overflow or submenus.

generateLayoutParams

open fun generateLayoutParams(attrs: AttributeSet!): Toolbar.LayoutParams!

getCollapseContentDescription

@Nullable open fun getCollapseContentDescription(): CharSequence?

Retrieve the currently configured content description for the collapse button view. This will be used to describe the collapse action to users through mechanisms such as screen readers or tooltips.

Return
CharSequence?: The collapse button's content description androidx.appcompat.R.attr#collapseContentDescription

getCollapseIcon

@Nullable open fun getCollapseIcon(): Drawable?

Return the current drawable used as the collapse icon.

Return
Drawable?: The collapse icon drawable androidx.appcompat.R.attr#collapseIcon

getContentInsetEnd

open fun getContentInsetEnd(): Int

Gets the ending content inset for this toolbar.

The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.

Return
Int: The ending content inset for this toolbar

getContentInsetEndWithActions

open fun getContentInsetEndWithActions(): Int

Gets the end content inset to use when action buttons are present.

Different content insets are often called for when additional buttons are present in the toolbar, as well as at different toolbar sizes. The larger value of getContentInsetEnd() and this value will be used during layout.

Return
Int: the end content inset used when a menu has been set in pixels

getContentInsetLeft

open fun getContentInsetLeft(): Int

Gets the left content inset for this toolbar.

The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.

Return
Int: The left content inset for this toolbar

getContentInsetRight

open fun getContentInsetRight(): Int

Gets the right content inset for this toolbar.

The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.

Return
Int: The right content inset for this toolbar

getContentInsetStart

open fun getContentInsetStart(): Int

Gets the starting content inset for this toolbar.

The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.

Return
Int: The starting content inset for this toolbar

getContentInsetStartWithNavigation

open fun getContentInsetStartWithNavigation(): Int

Gets the start content inset to use when a navigation button is present.

Different content insets are often called for when additional buttons are present in the toolbar, as well as at different toolbar sizes. The larger value of getContentInsetStart() and this value will be used during layout.

Return
Int: the start content inset used when a navigation icon has been set in pixels

getCurrentContentInsetEnd

open fun getCurrentContentInsetEnd(): Int

Gets the content inset that will be used on the ending side of the bar in the current toolbar configuration.

Return
Int: the current content inset end in pixels

getCurrentContentInsetLeft

open fun getCurrentContentInsetLeft(): Int

Gets the content inset that will be used on the left side of the bar in the current toolbar configuration.

Return
Int: the current content inset left in pixels

getCurrentContentInsetRight

open fun getCurrentContentInsetRight(): Int

Gets the content inset that will be used on the right side of the bar in the current toolbar configuration.

Return
Int: the current content inset right in pixels

getCurrentContentInsetStart

open fun getCurrentContentInsetStart(): Int

Gets the content inset that will be used on the starting side of the bar in the current toolbar configuration.

Return
Int: the current content inset start in pixels

getLogo

open fun getLogo(): Drawable!

Return the current logo drawable.

Return
Drawable!: The current logo drawable

getLogoDescription

open fun getLogoDescription(): CharSequence!

Return the description of the toolbar's logo.

Return
CharSequence!: A description of the logo

getMenu

open fun getMenu(): Menu!

Return the Menu shown in the toolbar.

Applications that wish to populate the toolbar's menu can do so from here. To use an XML menu resource, use inflateMenu(int).

Return
Menu!: The toolbar's Menu androidx.appcompat.R.attr#menu

getNavigationContentDescription

@Nullable open fun getNavigationContentDescription(): CharSequence?

Retrieve the currently configured content description for the navigation button view. This will be used to describe the navigation action to users through mechanisms such as screen readers or tooltips.

Return
CharSequence?: The navigation button's content description androidx.appcompat.R.attr#navigationContentDescription

getNavigationIcon

@Nullable open fun getNavigationIcon(): Drawable?

Return the current drawable used as the navigation icon.

Return
Drawable?: The navigation icon drawable androidx.appcompat.R.attr#navigationIcon

getOverflowIcon

@Nullable open fun getOverflowIcon(): Drawable?

Return the current drawable used as the overflow icon.

Return
Drawable?: The overflow icon drawable

getPopupTheme

open fun getPopupTheme(): Int
Return
Int: resource identifier of the theme used to inflate popup menus, or 0 if menus are inflated against the toolbar theme

getSubtitle

open fun getSubtitle(): CharSequence!

Return the subtitle of this toolbar.

Return
CharSequence!: The current subtitle

getTitle

open fun getTitle(): CharSequence!

Returns the title of this toolbar.

Return
CharSequence!: The current title.

getTitleMarginBottom

open fun getTitleMarginBottom(): Int
Return
Int: the bottom title margin in pixels

getTitleMarginEnd

open fun getTitleMarginEnd(): Int
Return
Int: the ending title margin in pixels

getTitleMarginStart

open fun getTitleMarginStart(): Int
Return
Int: the starting title margin in pixels

getTitleMarginTop

open fun getTitleMarginTop(): Int
Return
Int: the top title margin in pixels

hasExpandedActionView

open fun hasExpandedActionView(): Boolean

Check whether this Toolbar is currently hosting an expanded action view.

An action view may be expanded either directly from the MenuItem it belongs to or by user action. If the Toolbar has an expanded action view it can be collapsed using the collapseActionView() method.

Return
Boolean: true if the Toolbar has an expanded action view

hideOverflowMenu

open fun hideOverflowMenu(): Boolean

Hide the overflow items from the associated menu.

Return
Boolean: true if the menu was able to be hidden, false otherwise

inflateMenu

open fun inflateMenu(@MenuRes resId: Int): Unit

Inflate a menu resource into this toolbar.

Inflate an XML menu resource into this toolbar. Existing items in the menu will not be modified or removed.

Parameters
resId Int: ID of a menu resource to inflate androidx.appcompat.R.attr#menu

isOverflowMenuShowing

open fun isOverflowMenuShowing(): Boolean

Check whether the overflow menu is currently showing. This may not reflect a pending show operation in progress.

Return
Boolean: true if the overflow menu is currently showing

onHoverEvent

open fun onHoverEvent(ev: MotionEvent!): Boolean

onRtlPropertiesChanged

open fun onRtlPropertiesChanged(layoutDirection: Int): Unit

onTouchEvent

open fun onTouchEvent(ev: MotionEvent!): Boolean

setCollapseContentDescription

open fun setCollapseContentDescription(@StringRes resId: Int): Unit

Set a content description for the collapse button if one is present. The content description will be read via screen readers or other accessibility systems to explain the action of the collapse button.

Parameters
resId Int: Resource ID of a content description string to set, or 0 to clear the description androidx.appcompat.R.attr#collapseContentDescription

setCollapseContentDescription

open fun setCollapseContentDescription(@Nullable description: CharSequence?): Unit

Set a content description for the collapse button if one is present. The content description will be read via screen readers or other accessibility systems to explain the action of the navigation button.

Parameters
description CharSequence?: Content description to set, or null to clear the content description androidx.appcompat.R.attr#collapseContentDescription

setCollapseIcon

open fun setCollapseIcon(@DrawableRes resId: Int): Unit

Set the icon to use for the toolbar's collapse button.

The collapse button appears at the start of the toolbar when an action view is present .

Parameters
resId Int: Resource ID of a drawable to set androidx.appcompat.R.attr#collapseIcon

setCollapseIcon

open fun setCollapseIcon(@Nullable icon: Drawable?): Unit

Set the icon to use for the toolbar's collapse button.

The collapse button appears at the start of the toolbar when an action view is present .

Parameters
icon Drawable?: Drawable to set, may be null to use the default icon androidx.appcompat.R.attr#collapseIcon

setContentInsetEndWithActions

open fun setContentInsetEndWithActions(insetEndWithActions: Int): Unit

Sets the start content inset to use when action buttons are present.

Different content insets are often called for when additional buttons are present in the toolbar, as well as at different toolbar sizes. The larger value of getContentInsetEnd() and this value will be used during layout.

Parameters
insetEndWithActions Int: the inset to use when a menu has been set in pixels

setContentInsetStartWithNavigation

open fun setContentInsetStartWithNavigation(insetStartWithNavigation: Int): Unit

Sets the start content inset to use when a navigation button is present.

Different content insets are often called for when additional buttons are present in the toolbar, as well as at different toolbar sizes. The larger value of getContentInsetStart() and this value will be used during layout.

Parameters
insetStartWithNavigation Int: the inset to use when a navigation icon has been set in pixels

setContentInsetsAbsolute

open fun setContentInsetsAbsolute(contentInsetLeft: Int, contentInsetRight: Int): Unit

Sets the content insets for this toolbar.

The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.

Parameters
contentInsetLeft Int: Content inset for the toolbar's left edge
contentInsetRight Int: Content inset for the toolbar's right edge

setContentInsetsRelative

open fun setContentInsetsRelative(contentInsetStart: Int, contentInsetEnd: Int): Unit

Sets the content insets for this toolbar relative to layout direction.

The content inset affects the valid area for Toolbar content other than the navigation button and menu. Insets define the minimum margin for these components and can be used to effectively align Toolbar content along well-known gridlines.

Parameters
contentInsetStart Int: Content inset for the toolbar starting edge
contentInsetEnd Int: Content inset for the toolbar ending edge

setLogo

open fun setLogo(@DrawableRes resId: Int): Unit

Set a logo drawable from a resource id.

This drawable should generally take the place of title text. The logo cannot be clicked. Apps using a logo should also supply a description using setLogoDescription(int).

Parameters
resId Int: ID of a drawable resource

setLogo

open fun setLogo(drawable: Drawable!): Unit

Set a logo drawable.

This drawable should generally take the place of title text. The logo cannot be clicked. Apps using a logo should also supply a description using setLogoDescription(int).

Parameters
drawable Drawable!: Drawable to use as a logo

setLogoDescription

open fun setLogoDescription(@StringRes resId: Int): Unit

Set a description of the toolbar's logo.

This description will be used for accessibility or other similar descriptions of the UI.

Parameters
resId Int: String resource id

setLogoDescription

open fun setLogoDescription(description: CharSequence!): Unit

Set a description of the toolbar's logo.

This description will be used for accessibility or other similar descriptions of the UI.

Parameters
description CharSequence!: Description to set

setNavigationContentDescription

open fun setNavigationContentDescription(@StringRes resId: Int): Unit

Set a content description for the navigation button if one is present. The content description will be read via screen readers or other accessibility systems to explain the action of the navigation button.

Parameters
resId Int: Resource ID of a content description string to set, or 0 to clear the description androidx.appcompat.R.attr#navigationContentDescription

setNavigationContentDescription

open fun setNavigationContentDescription(@Nullable description: CharSequence?): Unit

Set a content description for the navigation button if one is present. The content description will be read via screen readers or other accessibility systems to explain the action of the navigation button.

Parameters
description CharSequence?: Content description to set, or null to clear the content description androidx.appcompat.R.attr#navigationContentDescription

setNavigationIcon

open fun setNavigationIcon(@DrawableRes resId: Int): Unit

Set the icon to use for the toolbar's navigation button.

The navigation button appears at the start of the toolbar if present. Setting an icon will make the navigation button visible.

If you use a navigation icon you should also set a description for its action using setNavigationContentDescription(int). This is used for accessibility and tooltips.

Parameters
resId Int: Resource ID of a drawable to set androidx.appcompat.R.attr#navigationIcon

setNavigationIcon

open fun setNavigationIcon(@Nullable icon: Drawable?): Unit

Set the icon to use for the toolbar's navigation button.

The navigation button appears at the start of the toolbar if present. Setting an icon will make the navigation button visible.

If you use a navigation icon you should also set a description for its action using setNavigationContentDescription(int). This is used for accessibility and tooltips.

Parameters
icon Drawable?: Drawable to set, may be null to clear the icon androidx.appcompat.R.attr#navigationIcon

setNavigationOnClickListener

open fun setNavigationOnClickListener(listener: OnClickListener!): Unit

Set a listener to respond to navigation events.

This listener will be called whenever the user clicks the navigation button at the start of the toolbar. An icon must be set for the navigation button to appear.

Parameters
listener OnClickListener!: Listener to set

setOnMenuItemClickListener

open fun setOnMenuItemClickListener(listener: Toolbar.OnMenuItemClickListener!): Unit

Set a listener to respond to menu item click events.

This listener will be invoked whenever a user selects a menu item from the action buttons presented at the end of the toolbar or the associated overflow.

Parameters
listener Toolbar.OnMenuItemClickListener!: Listener to set

setOverflowIcon

open fun setOverflowIcon(@Nullable icon: Drawable?): Unit

Set the icon to use for the overflow button.

Parameters
icon Drawable?: Drawable to set, may be null to clear the icon

setPopupTheme

open fun setPopupTheme(@StyleRes resId: Int): Unit

Specifies the theme to use when inflating popup menus. By default, uses the same theme as the toolbar itself.

Parameters
resId Int: theme used to inflate popup menus

See Also

setSubtitle

open fun setSubtitle(@StringRes resId: Int): Unit

Set the subtitle of this toolbar.

Subtitles should express extended information about the current content.

Parameters
resId Int: String resource ID

setSubtitle

open fun setSubtitle(subtitle: CharSequence!): Unit

Set the subtitle of this toolbar.

Subtitles should express extended information about the current content.

Parameters
subtitle CharSequence!: Subtitle to set

setSubtitleTextAppearance

open fun setSubtitleTextAppearance(context: Context!, @StyleRes resId: Int): Unit

Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.

setSubtitleTextColor

open fun setSubtitleTextColor(color: Int): Unit

Sets the text color of the subtitle, if present.

Parameters
color Int: The new text color in 0xAARRGGBB format

setSubtitleTextColor

open fun setSubtitleTextColor(@NonNull color: ColorStateList): Unit

Sets the text color of the subtitle, if present.

Parameters
color ColorStateList: The new text color

setTitle

open fun setTitle(@StringRes resId: Int): Unit

Set the title of this toolbar.

A title should be used as the anchor for a section of content. It should describe or name the content being viewed.

Parameters
resId Int: Resource ID of a string to set as the title

setTitle

open fun setTitle(title: CharSequence!): Unit

Set the title of this toolbar.

A title should be used as the anchor for a section of content. It should describe or name the content being viewed.

Parameters
title CharSequence!: Title to set

setTitleMargin

open fun setTitleMargin(start: Int, top: Int, end: Int, bottom: Int): Unit

Sets the title margin.

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

setTitleMarginBottom

open fun setTitleMarginBottom(margin: Int): Unit

Sets the bottom title margin in pixels.

Parameters
margin Int: the bottom title margin in pixels

setTitleMarginEnd

open fun setTitleMarginEnd(margin: Int): Unit

Sets the ending title margin in pixels.

Parameters
margin Int: the ending title margin in pixels

setTitleMarginStart

open fun setTitleMarginStart(margin: Int): Unit

Sets the starting title margin in pixels.

Parameters
margin Int: the starting title margin in pixels

setTitleMarginTop

open fun setTitleMarginTop(margin: Int): Unit

Sets the top title margin in pixels.

Parameters
margin Int: the top title margin in pixels

setTitleTextAppearance

open fun setTitleTextAppearance(context: Context!, @StyleRes resId: Int): Unit

Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.

setTitleTextColor

open fun setTitleTextColor(color: Int): Unit

Sets the text color of the title, if present.

Parameters
color Int: The new text color in 0xAARRGGBB format

setTitleTextColor

open fun setTitleTextColor(@NonNull color: ColorStateList): Unit

Sets the text color of the title, if present.

Parameters
color ColorStateList: The new text color

showOverflowMenu

open fun showOverflowMenu(): Boolean

Show the overflow items from the associated menu.

Return
Boolean: true if the menu was able to be shown, false otherwise

Protected methods

checkLayoutParams

protected open fun checkLayoutParams(p: LayoutParams!): Boolean

generateDefaultLayoutParams

protected open fun generateDefaultLayoutParams(): Toolbar.LayoutParams!

generateLayoutParams

protected open fun generateLayoutParams(p: LayoutParams!): Toolbar.LayoutParams!

onDetachedFromWindow

protected open fun onDetachedFromWindow(): Unit

onLayout

protected open fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int): Unit

onMeasure

protected open fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit

onRestoreInstanceState

protected open fun onRestoreInstanceState(state: Parcelable!): Unit

onSaveInstanceState

protected open fun onSaveInstanceState(): Parcelable!