Thanh ứng dụng (còn gọi là thanh thao tác) là một trong những thành phần thiết kế quan trọng nhất trong các hoạt động của ứng dụng, vì thanh này cung cấp cấu trúc hình ảnh và các phần tử tương tác quen thuộc với người dùng. Việc sử dụng thanh ứng dụng giúp ứng dụng của bạn nhất quán với các ứng dụng Android khác, cho phép người dùng nhanh chóng hiểu cách vận hành ứng dụng của bạn và có trải nghiệm tuyệt vời.
Sau đây là các chức năng chính của thanh ứng dụng:
Không gian riêng để cung cấp cho ứng dụng của bạn danh tính và cho biết vị trí của người dùng trong ứng dụng.
Quyền truy cập có thể dự đoán được vào các thao tác quan trọng, chẳng hạn như tìm kiếm.
Hỗ trợ điều hướng và chuyển đổi chế độ xem bằng thẻ hoặc trình đơn.
Hình 1. Thanh ứng dụng của ứng dụng Google Trang tính.
Phần tài liệu này mô tả cách sử dụng tiện ích AndroidX
Toolbar làm
thanh ứng dụng. Có nhiều cách khác để triển khai thanh ứng dụng, ví dụ: một số giao diện thiết lập ActionBar làm thanh ứng dụng theo mặc định, nhưng việc sử dụng Toolbar AppCompat giúp bạn dễ dàng thiết lập thanh ứng dụng hoạt động trên nhiều loại thiết bị nhất. Điều này cũng giúp bạn có thể tuỳ chỉnh thanh ứng dụng sau này trong quá trình phát triển ứng dụng.
Hãy tìm hiểu cách thêm thao tác vào thanh ứng dụng và trình đơn mục bổ sung của thanh ứng dụng, cũng như cách phản hồi khi người dùng chọn các thao tác đó.
Tìm hiểu cách sử dụng các tiện ích này để cung cấp chức năng nâng cao trong thanh ứng dụng.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[],[],null,["# Add the app bar\n\nTry the Compose way \nJetpack Compose is the recommended UI toolkit for Android. Learn how to add components in Compose. \n[App Bar →](/develop/ui/compose/components/app-bars) \n\nThe *app bar* , also known as the *action bar*, is one of the most important design\nelements in your app's activities, because it provides a visual structure and interactive elements\nthat are familiar to users. Using the app bar makes your app consistent with other Android apps,\nletting users quickly understand how to operate your app and have a great experience.\n| **Note:** With the release of Android 9.0 (API level 28), there is a version of the Support Library called [AndroidX](/jetpack/androidx) that is part of [Jetpack](/jetpack). The AndroidX library contains the existing Support Library and includes Jetpack components. \n|\n| You can continue to use the Support Library. Historical artifacts---those versioned 27 and earlier, and packaged as `android.support.*`---remain available on Google Maven. However, all newer library development occurs in the AndroidX library. \n|\n| We recommend using the AndroidX libraries in all new projects. Consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX as well.\n\nThe key functions of the app bar are as follows:\n\n- Dedicated space for giving your app an identity and indicating the user's location in the app.\n- Predictable access to important actions, such as search.\n- Support for navigation and view switching, using tabs or menus.\n\n**Figure 1.** The app bar from the Google Sheets app.\n\nThis documentation section describes how to use the AndroidX\n[Toolbar](/reference/androidx/appcompat/widget/Toolbar) widget as an\napp bar. There are other ways to implement an app bar---for example, some themes set up an\n[ActionBar](/reference/android/app/ActionBar) as an app bar by\ndefault---but using the AppCompat `Toolbar` makes it easier to set up an app bar that\nworks on the widest range of devices. It also gives you room to customize your app bar later in your\napp's development.\n\nTopics\n------\n\n\n**[Set up the app bar](/develop/ui/views/components/appbar/setting-up)**\n:\n Learn how to add a `Toolbar` widget to your activity and set it as the activity's\n app bar.\n\n\n**[Add and handle actions](/develop/ui/views/components/appbar/actions)**\n:\n Learn how to add actions to the app bar and its overflow menu, and how to respond when users\n choose those actions.\n\n\n**[Add an Up action](/develop/ui/views/components/appbar/up-action)**\n:\n Learn how to add an *Up* button to your app bar so users can navigate back to the app's\n home screen.\n\n\n**[Use action views and action providers](/develop/ui/views/components/appbar/action-views)**\n:\n Learn how to use these widgets to provide advanced functionality in your app bar."]]