CarToolbar
public
class
CarToolbar
extends ViewGroup
java.lang.Object | |||
↳ | android.view.View | ||
↳ | android.view.ViewGroup | ||
↳ | androidx.car.widget.CarToolbar |
A toolbar for building car applications.
CarToolbar provides a subset of features of Toolbar
through a driving safe UI. From
start to end, a CarToolbar provides the following elements:
- A navigation button. Similar to that in Toolbar, navigation button should
always provide access to other navigational destinations. If navigation button is to
be used as Up Button, its
OnClickListener
needs to explicitly invokeAppCompatActivity.onSupportNavigateUp()
- A title icon. A @
Drawable
shown before the title. - A title. A single line primary text that ellipsizes at the end.
- A subtitle. A single line secondary text that ellipsizes at the end.
- An overflow button. A button that opens the overflow menu.
CarMenuItem
in overflow menu will be shown as a CarListDialog
. Overflow menu
items with icons are not supported yet, i.e. only texts from CarMenuItem.getTitle()
will
be displayed.
One distinction between CarToolbar and Toolbar is that CarToolbar cannot be used as action bar
through AppCompatActivity.setSupportActionBar(Toolbar)
.
The CarToolbar has a fixed height of R.dimen.car_app_bar_height
.
Summary
XML attributes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CarToolbar_overflowIcon |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CarToolbar_titleIconEndMargin |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CarToolbar_titleIconStartMargin |
Inherited constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.ViewGroup
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.view.View
|
Inherited fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.view.View
|
Public constructors | |
---|---|
CarToolbar(Context context)
|
|
CarToolbar(Context context, AttributeSet attrs)
|
|
CarToolbar(Context context, AttributeSet attrs, int defStyleAttr)
|
|
CarToolbar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
|
Public methods | |
---|---|
ViewGroup.LayoutParams
|
generateLayoutParams(AttributeSet attrs)
|
List<CarMenuItem>
|
getMenuItems()
Returns a list of this |
CharSequence
|
getSubtitle()
Returns the subtitle of this toolbar. |
CharSequence
|
getTitle()
Returns the title of this toolbar. |
void
|
hideOverflowMenu()
Hides the overflow menu. |
boolean
|
isOverflowMenuShowing()
Returns |
void
|
setMenuItems(List<CarMenuItem> items)
Sets the list of |
void
|
setNavigationIcon(Drawable icon)
Set the icon to use for the toolbar's navigation button. |
void
|
setNavigationIcon(int iconResId)
Set the icon to use for the toolbar's navigation button. |
void
|
setNavigationIconContainerWidth(int width)
Sets the width of container for navigation icon. |
void
|
setNavigationIconOnClickListener(View.OnClickListener listener)
Sets a listener to respond to navigation events. |
void
|
setNavigationIconTint(int tint)
Sets the tint color for the navigation icon. |
void
|
setNavigationIconTint(ColorFilter colorFilter)
Sets the given |
void
|
setOverflowIcon(Drawable icon)
Sets the icon of the overflow menu button. |
void
|
setOverflowIcon(int iconResId)
Sets the icon of the overflow menu button. |
void
|
setSubtitle(CharSequence subtitle)
Sets the subtitle of this toolbar. |
void
|
setSubtitle(int resId)
Sets the subtitle of this toolbar. |
void
|
setSubtitleTextAppearance(int resId)
Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource. |
void
|
setTitle(CharSequence title)
Sets the title of this toolbar. |
void
|
setTitle(int resId)
Sets the title of this toolbar. |
void
|
setTitleIcon(Drawable icon)
Sets the title icon to use in the toolbar. |
void
|
setTitleIcon(int iconResId)
Sets the title icon to use in the toolbar. |
void
|
setTitleIconEndMargin(int margin)
Sets the end margin of the title icon. |
void
|
setTitleIconSize(int size)
Sets a new size for the title icon. |
void
|
setTitleIconStartMargin(int margin)
Sets the start margin of the title icon. |
void
|
setTitleTextAppearance(int resId)
Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource. |
void
|
showOverflowMenu()
Shows the overflow menu. |
Protected methods | |
---|---|
boolean
|
checkLayoutParams(ViewGroup.LayoutParams p)
|
ViewGroup.LayoutParams
|
generateDefaultLayoutParams()
|
ViewGroup.LayoutParams
|
generateLayoutParams(ViewGroup.LayoutParams p)
|
int
|
getSuggestedMinimumHeight()
|
void
|
onLayout(boolean changed, int left, int top, int right, int bottom)
|
void
|
onMeasure(int widthMeasureSpec, int heightMeasureSpec)
|
Inherited methods | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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
CarToolbar_overflowIcon
Related methods:
CarToolbar_titleIconEndMargin
Related methods:
CarToolbar_titleIconStartMargin
Related methods:
Public constructors
CarToolbar
public CarToolbar (Context context, AttributeSet attrs)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
CarToolbar
public CarToolbar (Context context, AttributeSet attrs, int defStyleAttr)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
defStyleAttr |
int |
CarToolbar
public CarToolbar (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
defStyleAttr |
int |
defStyleRes |
int |
Public methods
generateLayoutParams
public ViewGroup.LayoutParams generateLayoutParams (AttributeSet attrs)
Parameters | |
---|---|
attrs |
AttributeSet |
Returns | |
---|---|
ViewGroup.LayoutParams |
getMenuItems
public List<CarMenuItem> getMenuItems ()
Returns a list of this CarToolbar
's CarMenuItem
s, or
null
if none were set.
Returns | |
---|---|
List<CarMenuItem> |
getSubtitle
public CharSequence getSubtitle ()
Returns the subtitle of this toolbar.
Returns | |
---|---|
CharSequence |
The current subtitle, or null if none has been set.
|
getTitle
public CharSequence getTitle ()
Returns the title of this toolbar.
Returns | |
---|---|
CharSequence |
The current title. |
hideOverflowMenu
public void hideOverflowMenu ()
Hides the overflow menu.
isOverflowMenuShowing
public boolean isOverflowMenuShowing ()
Returns true
if the overflow menu is showing.
Returns | |
---|---|
boolean |
setMenuItems
public void setMenuItems (List<CarMenuItem> items)
Sets the list of CarMenuItem
s that will be displayed on this CarToolbar
.
Parameters | |
---|---|
items |
List : List of CarMenuItem s to display, null to remove all items.
|
setNavigationIcon
public void setNavigationIcon (Drawable icon)
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.
Parameters | |
---|---|
icon |
Drawable : Icon to set; null will hide the icon.
R.attr.navigationIcon
|
setNavigationIcon
public void setNavigationIcon (int iconResId)
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.
Parameters | |
---|---|
iconResId |
int : The resource id of the icon to set on the navigatino button.
R.attr.navigationIcon
|
setNavigationIconContainerWidth
public void setNavigationIconContainerWidth (int width)
Sets the width of container for navigation icon.
Navigation icon will be horizontally centered in its container. If the width of container is less than that of navigation icon, there will be no space on both ends of navigation icon.
Parameters | |
---|---|
width |
int : Width of container in pixels.
|
setNavigationIconOnClickListener
public void setNavigationIconOnClickListener (View.OnClickListener listener)
Sets 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 |
View.OnClickListener : Listener to set. |
See also:
setNavigationIconTint
public void setNavigationIconTint (int tint)
Sets the tint color for the navigation icon.
Parameters | |
---|---|
tint |
int : Color tint to apply.
R.attr.navigationIconTint
|
setNavigationIconTint
public void setNavigationIconTint (ColorFilter colorFilter)
Sets the given ColorFilter
as the tint for the navigation icon. A null
ColorFilter
will clear any set color filters.
Parameters | |
---|---|
colorFilter |
ColorFilter : Color filter to apply for the tint.
R.attr.navigationIconTint
|
setOverflowIcon
public void setOverflowIcon (Drawable icon)
Sets the icon of the overflow menu button.
Related XML Attributes:
Parameters | |
---|---|
icon |
Drawable : Icon to set. |
setOverflowIcon
public void setOverflowIcon (int iconResId)
Sets the icon of the overflow menu button.
Related XML Attributes:
Parameters | |
---|---|
iconResId |
int : Resource id of the drawable to use for the overflow menu button. |
setSubtitle
public void setSubtitle (CharSequence subtitle)
Sets the subtitle of this toolbar.
Subtitle should express extended information about the current content. Subtitle will appear underneath the title if the title exists.
Parameters | |
---|---|
subtitle |
CharSequence : Subtitle to set. null or empty string will hide the subtitle.
|
setSubtitle
public void setSubtitle (int resId)
Sets the subtitle of this toolbar.
Subtitles should express extended information about the current content. Subtitle will appear underneath the title if the title exists.
Parameters | |
---|---|
resId |
int : Resource ID of a string to set as the subtitle.
|
setSubtitleTextAppearance
public void setSubtitleTextAppearance (int resId)
Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.
Parameters | |
---|---|
resId |
int : Resource id of TextAppearance.
|
setTitle
public void setTitle (CharSequence title)
Sets 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.
null
or empty string will hide the title.
Parameters | |
---|---|
title |
CharSequence : Title to set.
|
setTitle
public void setTitle (int resId)
Sets 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.
|
setTitleIcon
public void setTitleIcon (Drawable icon)
Sets the title icon to use in the toolbar.
The title icon is positioned between the navigation button and the title.
Parameters | |
---|---|
icon |
Drawable : Icon to set; null will hide the icon.
R.attr.titleIcon
|
setTitleIcon
public void setTitleIcon (int iconResId)
Sets the title icon to use in the toolbar.
The title icon is positioned between the navigation button and the title.
Parameters | |
---|---|
iconResId |
int : Resource id of the drawable to use as the title icon.
R.attr.titleIcon
|
setTitleIconEndMargin
public void setTitleIconEndMargin (int margin)
Sets the end margin of the title icon.
Related XML Attributes:
Parameters | |
---|---|
margin |
int : End margin of the title icon in pixels. |
setTitleIconSize
public void setTitleIconSize (int size)
Sets a new size for the title icon.
Parameters | |
---|---|
size |
int : Size of the title icon dimensions in pixels.
R.attr.titleIconSize
|
setTitleIconStartMargin
public void setTitleIconStartMargin (int margin)
Sets the start margin of the title icon.
Related XML Attributes:
Parameters | |
---|---|
margin |
int : Start margin of the title icon in pixels. |
setTitleTextAppearance
public void setTitleTextAppearance (int resId)
Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.
Parameters | |
---|---|
resId |
int : Resource id of TextAppearance.
|
showOverflowMenu
public void showOverflowMenu ()
Shows the overflow menu.
Protected methods
checkLayoutParams
protected boolean checkLayoutParams (ViewGroup.LayoutParams p)
Parameters | |
---|---|
p |
ViewGroup.LayoutParams |
Returns | |
---|---|
boolean |
generateDefaultLayoutParams
protected ViewGroup.LayoutParams generateDefaultLayoutParams ()
Returns | |
---|---|
ViewGroup.LayoutParams |
generateLayoutParams
protected ViewGroup.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)
Parameters | |
---|---|
p |
ViewGroup.LayoutParams |
Returns | |
---|---|
ViewGroup.LayoutParams |
getSuggestedMinimumHeight
protected int getSuggestedMinimumHeight ()
Returns | |
---|---|
int |
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 |
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.