了解 Android Studio 界面
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android Studio 主窗口由图 1 中标注的几个逻辑区域组成。

图 1. Android Studio 主窗口。
- 工具栏:执行各种操作,其中包括运行应用和启动 Android 工具。
- 导航栏:在项目中导航,以及打开文件进行修改。此区域提供 Project 窗口中所示结构的精简视图。
- 编辑器窗口:创建和修改代码。编辑器可能因当前文件类型而异。例如,查看布局文件时,该编辑器会显示布局编辑器。
- 工具窗口栏:使用 IDE 窗口外部的按钮可展开或收起各个工具窗口。
- 工具窗口:执行特定任务,例如项目管理、搜索和版本控制等。您可以展开和折叠这些窗口。
- 状态栏:显示项目和 IDE 本身的状态以及任何警告或消息。
您可以隐藏或移动工具栏和工具窗口,以此调整主窗口,腾出更多屏幕空间。您还可以通过键盘快捷键使用大多数 IDE 功能。
如需在源代码、数据库、操作、界面元素等对象中搜索,请执行以下操作之一:
- 连按两次 Shift 键。
- 点击 Android Studio 窗口右上角的放大镜。
此功能非常实用,例如在您忘记如何触发特定 IDE 操作时,可以利用此功能进行查找。
Android Studio 不使用预设窗口,而是根据情境在您执行操作时自动显示相关工具窗口。默认情况下,最常用的工具窗口会固定在应用窗口边缘的工具窗口栏上。
使用以下方法在工具窗口中导航:
- 如需展开或收起工具窗口,请在工具窗口栏中点击该工具的名称。您还可以拖动、固定、取消固定、关联和分离工具窗口。
- 若要恢复当前工具窗口的默认布局,请依次点击 Window > Restore Default Layout。若要自定义默认布局,请依次点击 Window > Store Current Layout as Default。
- 如需显示或隐藏整个工具窗口栏,请点击 Android Studio 窗口左下角的窗口图标
。
- 如需找到特定工具窗口,请将鼠标指针悬停在窗口图标上方,并从菜单中选择相应的工具窗口。
您也可以使用键盘快捷键打开工具窗口。表 1 列出了最常用工具窗口的快捷键。
表 1. 工具窗口的键盘快捷键
工具窗口 |
Windows 和 Linux |
macOS |
项目 |
Alt+1 |
Command+1 |
版本控制 |
Alt+9 |
Command+9 |
运行 |
Shift+F10 |
Ctrl+R |
调试 |
Shift+F9 |
Ctrl+D |
Logcat |
Alt+6 |
Command+6 |
返回编辑器 |
Esc |
Esc |
隐藏所有工具窗口 |
Ctrl+Shift+F12 |
Command+Shift+F12 |
若要隐藏所有工具栏、工具窗口和编辑器标签页,请依次点击 View > Enter Distraction Free Mode。如需退出 Distraction Free Mode,请依次点击 View > Exit Distraction Free Mode。
您可以使用“快速搜索”在 Android Studio 中的大多数工具窗口中执行搜索和过滤。如需使用“快速搜索”,请选择工具窗口,然后输入您的搜索查询。
代码补全
Android Studio 有三种代码补全类型,您可以通过键盘快捷键使用这些类型。
表 2. 代码补全功能的键盘快捷键
类型 |
说明 |
Windows 和 Linux |
macOS |
基本补全
|
显示对变量、类型、方法和表达式等的基本建议。如果连续两次调用基本补全,系统将显示更多结果,包括私有成员和非导入静态成员。 |
Ctrl+空格键 |
Ctrl+空格键 |
智能补全 |
根据上下文显示相关选项。智能自动补全可识别预期类型和数据流。如果连续两次调用智能自动补全,系统将显示更多结果,包括链。 |
Ctrl+Shift+空格键 |
Ctrl+Shift+空格键 |
语句补全 |
补全当前语句,添加缺失的圆括号、大括号、花括号和格式等。 |
Ctrl+Shift+Enter |
Command+Shift+Enter |
若要执行快速修复并显示建议的操作,请按 Alt+Enter。
查找示例代码
Android Studio 中的代码示例浏览器可以帮助您根据项目中当前突出显示的符号查找 Google 提供的优质 Android 示例代码。如需了解详情,请参阅查找示例代码。
导航
以下是一些助您在 Android Studio 中导航的提示。
使用最近文件操作可在最近访问过的文件之间切换:
按 Ctrl+E(在 macOS 中,按 Command+E)可调出最近文件操作。默认情况下,系统将选择最后一次访问的文件。在此操作中,您还可以通过左侧列访问任何工具窗口。
使用文件结构操作可查看当前文件的结构,还可快速前往当前文件的任何部分:
按 Ctrl+F12(在 macOS 中,按 Command+F12)可调出文件结构操作。
使用前往类操作可搜索并前往项目中的特定类。前往类支持复杂的表达式,包括驼峰(让您可使用某元素的驼峰式大小写名称中的大写字母进行搜索)、路径、行导航(让您可前往文件内的特定行)和中间名匹配(让您可搜索类名称的一部分)等。如果连续两次调用此操作,系统将显示项目类以外的结果。
按 Ctrl+N(在 macOS 中,按 Command+O)可调出前往类操作。
使用前往文件操作可前往文件或文件夹:
按 Ctrl+Shift+N(在 macOS 中,按 Command+Shift+O)可调出前往文件操作。如需搜索文件夹(而不是文件),请在表达式末尾添加“/”。
使用前往符号操作可按名称前往某个方法或字段:
按 Ctrl+Shift+Alt+N(在 macOS 中,按 Command+Option+O)可调出前往符号操作。
按 Alt+F7(在 macOS 中,按 Option+F7)可查找引用当前光标位置处的类、方法、字段、参数或语句的所有代码片段。
在您编辑时,Android Studio 会自动应用代码样式设置中指定的格式和样式。您可以通过编程语言自定义代码样式设置,其中包括指定制表符和缩进、空格、换行、花括号以及空白行的规范。
如需自定义代码样式设置,请依次点击 File > Settings > Editor > Code Style(在 macOS 中,请依次点击 Android Studio > Preferences > Editor > Code Style)。
虽然 IDE 会在您执行操作时自动应用格式,但您也可以显式调用重新格式化代码操作。按 Ctrl+Alt+L(在 macOS 中,按 Option+Command+L)可调用此操作。按 Ctrl+Alt+I(在 macOS 中,按 Ctrl+Option+I)可自动缩进所有行。

图 2. 格式化前的代码。

图 3. 格式化后的代码。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Get to know the Android Studio UI\n\nThe Android Studio main window consists of several logical areas, shown in\nFigure 1.\n\n\n**Figure 1.** The Android Studio main window.\n\n1. **Toolbar:** Carry out a wide range of actions, including running your app and launching Android tools.\n2. **Navigation bar:** Navigate through your project and open files for editing. It provides a more compact view of the structure visible in the **Project** window.\n3. **Editor window:** Create and modify code. Depending on the current file type, the editor can change. For example, when viewing a layout file, the editor displays the Layout Editor.\n4. **Tool window bar:** Use the buttons on the outside of the IDE window to expand or collapse individual tool windows.\n5. **Tool windows:** Access specific tasks like project management, search, version control, and more. You can expand them and collapse them.\n6. **Status bar:** Display the status of your project and the IDE itself, as well as any warnings or messages.\n\nTo organize the main window for more screen space, hide or move the toolbars\nand tool windows. You can also use\n[keyboard shortcuts](/studio/intro/keyboard-shortcuts) to\naccess most IDE features.\n\nTo search across your source code, databases, actions,\nelements of the user interface, and more, do one of the following:\n\n- Double-press the \u003ckbd\u003eShift\u003c/kbd\u003e key.\n- Click the magnifying glass in the upper right-hand corner of the Android Studio window.\n\nThis can be very useful if, for example, you are trying to\nlocate a particular IDE action that you have forgotten how to trigger.\n\nTool windows\n------------\n\nInstead of using preset perspectives, Android Studio follows your context and\nautomatically brings up relevant tool windows as you work. By default, the most\ncommonly used tool windows are pinned to the tool window bar at the edges of\nthe application window.\n\nNavigate the tool window using the following:\n\n- To expand or collapse a tool window, click the tool's name in the tool window bar. You can also drag, pin, unpin, attach, and detach tool windows.\n- To return to the default layout of the current tool window, click **Window \\\u003e Restore Default Layout** . To customize your default layout, click **Window \\\u003e Store Current Layout as Default**.\n- To show or hide the entire tool window bar, click the window icon in the bottom left-hand corner of the Android Studio window.\n- To locate a specific tool window, hover over the window icon and select the tool window from the menu.\n\nYou can also use [keyboard shortcuts](/studio/intro/keyboard-shortcuts) to\nopen tool windows. Table 1 lists the shortcuts for the most common tool windows.\n\n\n**Table 1.** Keyboard shortcuts for tool windows\n\n| Tool window | Windows and Linux | macos |\n|-----------------------|------------------------------|------------------------------|\n| Project | \u003ckbd\u003eAlt+1\u003c/kbd\u003e | \u003ckbd\u003eCommand+1\u003c/kbd\u003e |\n| Version Control | \u003ckbd\u003eAlt+9\u003c/kbd\u003e | \u003ckbd\u003eCommand+9\u003c/kbd\u003e |\n| Run | \u003ckbd\u003eShift+F10\u003c/kbd\u003e | \u003ckbd\u003eControl+R\u003c/kbd\u003e |\n| Debug | \u003ckbd\u003eShift+F9\u003c/kbd\u003e | \u003ckbd\u003eControl+D\u003c/kbd\u003e |\n| Logcat | \u003ckbd\u003eAlt+6\u003c/kbd\u003e | \u003ckbd\u003eCommand+6\u003c/kbd\u003e |\n| Return to Editor | \u003ckbd\u003eEsc\u003c/kbd\u003e | \u003ckbd\u003eEsc\u003c/kbd\u003e |\n| Hide All Tool Windows | \u003ckbd\u003eControl+Shift+F12\u003c/kbd\u003e | \u003ckbd\u003eCommand+Shift+F12\u003c/kbd\u003e |\n\nTo hide all toolbars, tool windows, and editor tabs, click\n**View \\\u003e Enter Distraction Free Mode** . To exit Distraction Free Mode, click\n**View \\\u003e Exit Distraction Free Mode**.\n\nUse *Speed Search* to search and filter within most tool windows\nin Android Studio. To use Speed Search, select the tool window and then type\nyour search query.\n\nCode completion\n---------------\n\nAndroid Studio has three types of code completion, which you can access using\nkeyboard shortcuts.\n\n\n**Table 2.** Keyboard shortcuts for code completion\n\n| Type | Description | Windows and Linux | macOS |\n|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|--------------------------------|\n| Basic Completion | Displays basic suggestions for variables, types, methods, expressions, and so on. If you call basic completion twice in a row, you see more results, including private members and non-imported static members. | \u003ckbd\u003eControl+Space\u003c/kbd\u003e | \u003ckbd\u003eControl+Space\u003c/kbd\u003e |\n| Smart Completion | Displays relevant options based on the context. Smart completion is aware of the expected type and data flows. If you call Smart Completion twice in a row, you see more results, including chains. | \u003ckbd\u003eControl+Shift+Space\u003c/kbd\u003e | \u003ckbd\u003eControl+Shift+Space\u003c/kbd\u003e |\n| Statement Completion | Completes the current statement for you, adding missing parentheses, brackets, braces, formatting, and so on. | \u003ckbd\u003eControl+Shift+Enter\u003c/kbd\u003e | \u003ckbd\u003eCommand+Shift+Enter\u003c/kbd\u003e |\n\nTo perform quickfixes and show intention actions, press\n\u003ckbd\u003eAlt+Enter\u003ckbd\u003e.\u003c/kbd\u003e\u003c/kbd\u003e\n\nFind sample code\n----------------\n\nThe Code Sample Browser in Android Studio helps you find high-quality,\nGoogle-provided Android code samples based on the currently highlighted symbol\nin your project. For more information, see\n[Find sample code](/studio/write/sample-code).\n\nNavigation\n----------\n\nHere are some tips to help you navigate Android Studio.\n\n- Use the **Recent Files** action to switch between your recently accessed\n files:\n\n To bring up the **Recent Files** action, press\n \u003ckbd\u003eControl+E\u003c/kbd\u003e (\u003ckbd\u003eCommand+E\u003c/kbd\u003e on macOS). By default, the\n last accessed file is selected. With this action, you can also access\n any tool window through the left column.\n- Use the **File Structure** action to view the structure of the current file\n and quickly navigate to any part of your current file:\n\n To bring up the **File Structure** action, press \u003ckbd\u003eControl+F12\u003c/kbd\u003e\n (\u003ckbd\u003eCommand+F12\u003c/kbd\u003e on macOS).\n- Use the **Navigate to Class** action to search for and navigate to a\n specific class in your project. **Navigate to Class** supports sophisticated\n expressions, including *camel humps* (which lets you search by the capitalized\n letters in an element's camel-cased name), paths, *line navigate to* (which\n lets you navigate to a specific line within the file), *middle name\n matching* (which lets you search for a part of the class name), and many more.\n If you call it twice in a row, it shows you the\n results out of the project classes.\n\n To bring up the **Navigate to Class** action, press \u003ckbd\u003eControl+N\u003c/kbd\u003e\n (\u003ckbd\u003eCommand+O\u003c/kbd\u003e on macOS).\n- Use the **Navigate to File** action to navigate to a file or folder:\n\n To bring up **Navigate to File** action, press \u003ckbd\u003eControl+Shift+N\u003c/kbd\u003e\n (\u003ckbd\u003eCommand+Shift+O\u003c/kbd\u003e on macOS). To search for folders rather than\n files, add a \"/\" at the end of your expression.\n- Use the **Navigate to Symbol** action to navigate to a method or field by\n name:\n\n To bring up the **Navigate to Symbol** action, press\n \u003ckbd\u003eControl+Shift+Alt+N\u003c/kbd\u003e (\u003ckbd\u003eCommand+Option+O\u003c/kbd\u003e on macOS).\n- To find all the pieces of code referencing the class, method, field,\n parameter, or statement at the current cursor position, press\n \u003ckbd\u003eAlt+F7\u003c/kbd\u003e (\u003ckbd\u003eOption+F7\u003c/kbd\u003e on macOS).\n\nStyle and formatting\n--------------------\n\nAs you edit, Android Studio automatically applies formatting and styles as\nspecified in your code style settings. You can customize the code style\nsettings by programming language, including specifying conventions for tabs and\nindents, spaces, wrapping and braces, and blank lines.\n\nTo customize your code\nstyle settings, click **File \\\u003e Settings \\\u003e Editor \\\u003e Code Style** (**Android\nStudio \\\u003e Preferences \\\u003e Editor \\\u003e Code Style** on macOS.)\n\nAlthough the IDE automatically applies formatting as you work, you can also\nexplicitly call the **Reformat Code** action. To call the action,\npress \u003ckbd\u003eControl+Alt+L\u003c/kbd\u003e (\u003ckbd\u003eOpt+Command+L\u003c/kbd\u003e on macOS). To\nauto-indent all lines, press\n\u003ckbd\u003eControl+Alt+I\u003c/kbd\u003e (\u003ckbd\u003eControl+Option+I\u003c/kbd\u003e on macOS).\n\n\n**Figure 2.** Code before formatting.\n\n\n**Figure 3.** Code after formatting."]]