2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
ツールバー
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
電話アプリは、パッケージ名が com.android.car.ui.toolbar.Toolbar
のシャーシ ツールバーを使用します。ツールバーをカスタマイズする最初のステップは、レイアウト ファイルをオーバーレイすることです。レイアウト ファイルは、レガシー ツールバーの場合は car_ui_toolbar.xml
と car_ui_toolbar_two_row.xml
、基本レイアウト バージョンの場合は car_ui_base_layout_toolbar.xml
です。レイアウトの各バージョンで、次の各ビューに対してそれぞれの ID を指定する必要があります。
id |
ビューの種類 |
説明 |
car_ui_toolbar_background /td> | android.view.View |
基本レイアウトでは非推奨になっていますが、以前のツールバー スタイルで高さを決定するために使用されます。 |
car_ui_toolbar_tabs |
com.android.car.ui.toolbar.TabLayout |
タブの位置。 |
car_ui_toolbar_nav_icon |
android.widget.ImageView |
戻る、閉じる、下矢印の各ボタン。 |
car_ui_toolbar_logo |
android.widget.ImageView |
car_ui_toolbar_logo_ fills_nav_icon_space が true の場合のロゴ。 |
car_ui_toolbar_nav_icon_container |
android.view.ViewGroup |
car_ui_toolbar_logo と car_ui_toolbar_nav_icon を保持するコンテナ。 |
car_ui_toolbar_menu_items_container |
android.view.ViewGroup |
MenuItem を格納する ViewGroup。 |
car_ui_toolbar_title |
android.widget.TextView |
ツールバーのタイトル。 |
car_ui_toolbar_title_logo_container |
android.view.ViewGroup |
car_ui_toolbar_title_logo のコンテナ。コンテナは、ImageView の代わりに表示され(または非表示にされ)ます。 |
car_ui_toolbar_title_logo |
android.widget.ImageView |
car_ui_toolbar_logo_ fills_nav_icon_space が false の場合のロゴ。 |
car_ui_toolbar_search_view_container |
android.widget.FrameLayout |
検索ビューがインフレートされる対象コンテナ。これにより、検索バーのない画面でのインフレーション時間が短縮されます。 |
car_ui_toolbar_progress_bar |
android.widget.ProgressBar |
進行状況バー。 |
次に、car_ui_toolbar_search_view.xml
もカスタマイズする必要があります。これには検索バーが含まれ、次のビューが必要です。
id |
ビューの種類 |
説明 |
car_ui_toolbar_search_bar |
android.widget.EditText |
ユーザーが検索するテキストを入力する EditText。 |
car_ui_toolbar_search_icon |
android.widget.ImageView |
通常、アイコンは検索アイコンを示しますが、アプリケーションで変更できます。 |
car_ui_toolbar_search_close |
android.view.View |
クリックすると検索ボックスを消去するビュー |
レイアウトに加えて、次のブール値属性を使用してツールバーをカスタマイズできます。
属性 |
説明 |
car_ui_toolbar_tabs_on_second_row |
タブが表示されるときにタイトルを非表示にするかどうかを決定します。 |
car_ui_toolbar_nav_icon_reserve_space |
ナビゲーション アイコンが非表示の場合に、ナビゲーション アイコンのスペースを埋めるためにタイトルを左に移動する必要があるかどうかを決定します。 |
car_ui_toolbar_logo_fills_nav_icon_space |
ナビゲーション ボタンがない場合は、ナビゲーション ボタンと同じスペースにロゴを表示します。 |
car_ui_toolbar_show_logo |
ツールバーでロゴの表示を完全に無効にするには、これを false に設定します。 |
これらのビューは、ToolbarControllerImpl
メソッドの setState
に基づいて表示され、または非表示にされ、あるいは変更されます。表示されるビューと表示のタイミングの詳細については、前述のメソッドをご覧ください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 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."]]