Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Toolbar
Stay organized with collections
Save and categorize content based on your preferences.
Dialer uses the chassis toolbar with a package name of
com.android.car.ui.toolbar.Toolbar
.
The first step to customizing the toolbar is to overlay the layout file, which is
car_ui_toolbar.xml
and car_ui_toolbar_two_row.xml
for the legacy toolbar,
and car_ui_base_layout_toolbar.xml
for the base layout version. In each version of the
layout, each of the following views must be provided with the respective ids:
id |
View type |
Description |
car_ui_toolbar_background /td>
| android.view.View |
Deprecated for base layouts, but used with the previous toolbar style to determine height. |
car_ui_toolbar_tabs |
com.android.car.ui.toolbar.TabLayout |
Location of tabs. |
car_ui_toolbar_nav_icon |
android.widget.ImageView |
The Back, Close, Down button. |
car_ui_toolbar_logo |
android.widget.ImageView |
The logo, when car_ui_toolbar_logo_ fills_nav_icon_space is true . |
car_ui_toolbar_nav_icon_container |
android.view.ViewGroup |
A container to hold car_ui_toolbar_logo and car_ui_toolbar_nav_icon . |
car_ui_toolbar_menu_items_container |
android.view.ViewGroup |
A ViewGroup to contain MenuItems. |
car_ui_toolbar_title |
android.widget.TextView |
The title of the toolbar. |
car_ui_toolbar_title_logo_container |
android.view.ViewGroup |
A container for the car_ui_toolbar_title_logo . The container will be displayed (or
hidden) instead of the ImageView. |
car_ui_toolbar_title_logo |
android.widget.ImageView |
The logo, when car_ui_toolbar_logo_ fills_nav_icon_space is false |
car_ui_toolbar_search_view_container |
android.widget.FrameLayout |
A container into which the search view is to be inflated. This reduces inflation durations on
screens without Search bars. |
car_ui_toolbar_progress_bar |
android.widget.ProgressBar |
A progress bar. |
Next, you must also customize car_ui_toolbar_search_view.xml
, which contains the
Search bar, which must have the following views:
id |
View type |
Description |
car_ui_toolbar_search_bar |
android.widget.EditText |
The EditText where the user types text to search. |
car_ui_toolbar_search_icon |
android.widget.ImageView |
An icon, that normally shows a search icon but can be changed by applications. |
car_ui_toolbar_search_close |
android.view.View |
A view that when clicked will clear the search box |
In addition to the layout, you can use these Boolean attributes to customize the toolbar:
Attribute |
Description |
car_ui_toolbar_tabs_on_second_row |
Determines whether or not to hide the title when tabs are displayed. |
car_ui_toolbar_nav_icon_reserve_space |
Determines if the title should be moved to the left to occupy the space of the Navigation icon
when the Navigation icon is hidden. |
car_ui_toolbar_logo_fills_nav_icon_space |
Display the logo in the same space as the Navigation button when no Navigation button is
present. |
car_ui_toolbar_show_logo |
To permanently disable the display of a logo in the toolbar, set this to false . |
These views are displayed, hidden, or changed based on the setState
of the
ToolbarControllerImpl
method. For specifics about which view is displayed and when,
see that method.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-08-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-26 UTC."],[],[],null,["# Toolbar\n\nDialer uses the chassis toolbar with a package name of\n`com.android.car.ui.toolbar.Toolbar`.\n\nThe first step to customizing the toolbar is to overlay the layout file, which is\n`car_ui_toolbar.xml` and `car_ui_toolbar_two_row.xml` for the legacy toolbar,\nand `car_ui_base_layout_toolbar.xml` for the base layout version. In each version of the\nlayout, each of the following views must be provided with the respective ids:\n\n| id | View type | Description |\n|----------------------------------------|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------|\n| `car_ui_toolbar_background`/td\\\u003e | `android.view.View` | Deprecated for base layouts, but used with the previous toolbar style to determine height. |\n| `car_ui_toolbar_tabs` | `com.android.car.ui.toolbar.TabLayout` | Location of tabs. |\n| `car_ui_toolbar_nav_icon` | `android.widget.ImageView` | The Back, Close, Down button. |\n| `car_ui_toolbar_logo` | `android.widget.ImageView` | The logo, when car_ui_toolbar_logo_ fills_nav_icon_space is `true`. |\n| `car_ui_toolbar_nav_icon_container` | `android.view.ViewGroup` | A container to hold `car_ui_toolbar_logo` and `car_ui_toolbar_nav_icon`. |\n| `car_ui_toolbar_menu_items_container` | `android.view.ViewGroup` | A ViewGroup to contain MenuItems. |\n| `car_ui_toolbar_title` | `android.widget.TextView` | The title of the toolbar. |\n| `car_ui_toolbar_title_logo_container` | `android.view.ViewGroup` | A container for the `car_ui_toolbar_title_logo`. The container will be displayed (or hidden) instead of the ImageView. |\n| `car_ui_toolbar_title_logo` | `android.widget.ImageView` | The logo, when car_ui_toolbar_logo_ fills_nav_icon_space is `false` |\n| `car_ui_toolbar_search_view_container` | `android.widget.FrameLayout` | A container into which the search view is to be inflated. This reduces inflation durations on screens without Search bars. |\n| `car_ui_toolbar_progress_bar` | `android.widget.ProgressBar` | A progress bar. |\n\nNext, you must also customize `car_ui_toolbar_search_view.xml`, which contains the\nSearch bar, which must have the following views:\n\n| id | View type | Description |\n|-------------------------------|----------------------------|--------------------------------------------------------------------------------|\n| `car_ui_toolbar_search_bar` | `android.widget.EditText` | The EditText where the user types text to search. |\n| `car_ui_toolbar_search_icon` | `android.widget.ImageView` | An icon, that normally shows a search icon but can be changed by applications. |\n| `car_ui_toolbar_search_close` | `android.view.View` | A view that when clicked will clear the search box |\n\nIn addition to the layout, you can use these Boolean attributes to customize the toolbar:\n\n| Attribute | Description |\n|--------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|\n| `car_ui_toolbar_tabs_on_second_row` | Determines whether or not to hide the title when tabs are displayed. |\n| `car_ui_toolbar_nav_icon_reserve_space` | Determines if the title should be moved to the left to occupy the space of the Navigation icon when the Navigation icon is hidden. |\n| `car_ui_toolbar_logo_fills_nav_icon_space` | Display the logo in the same space as the Navigation button when no Navigation button is present. |\n| `car_ui_toolbar_show_logo` | To permanently disable the display of a logo in the toolbar, set this to `false`. |\n\nThese views are displayed, hidden, or changed based on the `setState` of the\n`ToolbarControllerImpl` method. For specifics about which view is displayed and when,\nsee that method."]]