Chapter II: Overview of Android Studio (i) [Learn Android Studio Chinese Course]

Source: Internet
Author: User
Tags filegroup

Learn about the Android Studio Chinese tutorial Android Studio is a windowed environment. to maximize the use of limited screen space and prevent you from being overwhelmed, Android studio displays only a small subset of available windows at any given time. Some windows in these windows are context sensitive and appear only when the context is appropriate, while others remain hidden until you decide to display them, or otherwise remain visible until you decide to hide them. to get the most out of Android Studio, you need to understand the capabilities of these windows and how and when to display them. In this chapter, we'll show you how to manage Windows in Android Studio.

< translation >Android Studio is a windowing development environment. In order to make full use of the limited screen space, do not let you shackled,
Android Studio displays only a small subset of available windows at specific times. In addition to some context-sensitive windows and contextual windows that appear outside, the others are still hidden unless you actively open them. Or, conversely, some visible windows until you actively hide them. To make the most of your Android studio, you need to understand how these Windows function and when to show them. In this chapter, we'll show you how to manage Windows in Android Studio,

any of the basic features of the Integrated development environment (IDE) are navigation. Android projects are usually made up of many packages, directories and files, and an Android project with a very low level of complexity can contain hundreds of of these resources. The productivity of Android studio will depend to a large extent on how comfortable you are within these assets and navigating within those assets. in This chapter, we'll show you how to navigate in Android studio.

< translation >the underlying functionality of any integrated development environment (IDE) is navigation. Android projects are usually made up of many packages, directories and files, and even a slightly more complex Android project can contain hundreds of of these resources. The efficiency of your use of Android Studio is largely dependent on how comfortable you are with these resources. In this chapter, we'll also show you how to use navigation in Android Studio.

Finally, we'll show you how to use the Help system in Android Studio. to make the most of this chapter, open the HelloWorld project that we created in chapter 1th. If this project is already open in Android Studio, you are ready to start. refer to Figure 2-1 when discussing the following navigation features.

< translation >Finally, we'll show you how to use the Help system in Android Studio. To fully understand this chapter, we open the HelloWorld project created in Chapter one. If the project is already open in Android Studio, you are ready to do so. Please refer to Figure 2-1, we will discuss the following navigation functions.


Figure 2-1. integrated development environment for Android Studio
< translation > Figure 2-1 The integrated development environment for Android Studio

EditEditor The primary purpose of any IDE is to edit the file. As expected, the window that allows users to edit files in Android Studio is located in the middle pane of the IDE. The Editor window is unique in the window and is always visible and always in the center pane. In fact, the editor window is a very common feature of Android Studio, and from here we'll simply call it an editor. all other windows in Android Studio are called tool windows and clustered in the left pane (left pane, right pane, and right pane) around the editor.

< translation > The primary purpose of any IDE is to edit the file. As expected, windows in Android Studio that allow users to edit files are located in the center of the IDE. In all the Windows, the edit window is the only one that is always visible and is in the center of the window . In fact, the editing window is everywhere in Android studio, so from now on we call it an editor. All other windows around the editor in Android Studio are called tool windows and side windows (left, bottom, right).

The Editor is a tabbed window, which, in this context, resembles a contemporary web browser. When you open a file from a tool window, keyboard shortcut, or context menu, the file appears as a tab in the editor. as you have discovered when building the first project HelloWorld, the Mainactivity.java and Activity_main.xml files are automatically loaded into the editor as tabs. Android Studio tries to predict which files may start editing, and then automatically opens them as tabs in the editor after the New Project Wizard finishes. in fact, you can open any file in the editor, but the original image and sound file cannot be edited in Android Studio. You can also drag and drop files from the tool window onto the editor; doing so will open the file as a label in the editor

< translation >The Editor is a tabbed window similar to a modern web browser. When you open a file from a tool window, keyboard shortcut, or context menu , the file is displayed as a tab in the editor . New first project--helloworld, Mainactivity.java and activity_main.xml are automatically loaded as tabs in the editor. Android Studio tries to start editing which files, You can then automatically open the editor as almost any file after the New Project Wizard finishes, although the original image and sound files are not yet editable in Android studio. You can also drag files from the tool window to the editor, which can be opened directly as tabs in the editor. Editor

The top part of the Editor tab. the left edge of the editor is the gutter, along the right edge of the editor is the marker bar. Let's check each one in turn.

< translation >
above the editor is the Edit tab. On the left edge is the Edge column, and the right edge is the formula bar. Let's start exploring.

Edit Labeledit Tab to navigate in the Editor tab of Android Studio, use the ALT + RIGHT ARROW | Ctrl + RIGHT ARROW or ALT + left?? Arrows | Ctrl + LEFT ARROW key. Of course, you can select an edit tab with your mouse at any time. the options for the Editor tab are in the window? Editor tab in the main menu bar. Any action you choose from this menu applies to the currently selected tab. Move the mouse over the Mainactivity.java tab and right-click (Ctrl-click Mac). in the result context menu shown in 2-2, you will notice the "window"? " Many of the same options found in the Editor tab. In this context menu, select the Tabs Placement submenu. menu Options "Up, down, left, right" allow you to move the tab bar. move the tab bar to the right or left to accommodate more visible labels, but at the expense of screen space.

< translation >In Android Studio, you can toggle tabs by using the CTRL key or ALT + left or right arrows. Of course, you can also select the Edit tab with the mouse . The options for the Editor tab are located under the Window > Editor tab of the main menu bar. Any action you make here will be applied to the currently selected tab . Place your mouse on the Mainactivity.java tab and right-click on it (under the Apple Ctrl key). As shown in 2-2, in the generated menu you will see a lot of the same options as the window> Editor tabs download. From this menu, select the Tabs Placement submenu. This menu option allows you to move the tabs up, down, left, and right. Moving a tab to the left or right holds more visible tabs , but it takes up a portion of the screen.



Figure 2-2. Editor Tab context menu
< translation > Figure 2-2 Content menu Edit tab

the Editor tab context menu for closing and closing all operations is very simple. Close other actions to close all tabs except the active tab. the vertical split and split horizontal actions are used to subdivide the editor into multiple panes. Vertical Segmentation is especially useful if you want to compare two files side by side. Although this nested split utility may be quickly reduced, you can divide the panes infinitely. You can also drag and drop files from other Windows into any pane of the editor, or from one pane to another. Closing the last tab of the pane causes the entire pane to disappear.

< translation >It is clear that all actions are closed and closed on the editor menu. And you want to close all the tabs besides, you should use the other to close. The vertical and horizontal split operations are used to divide the editor into Windows if you want to compare two files then split vertically will be useful. You can subdivide indefinitely, although the effect of this nesting is greatly reduced. You can also drag files from other Windows to any panel in the editor, or from one panel to another panel. When the last tab is closed, the entire panel disappears.

GutterEdge Column grooves are used to convey information about your code. Perhaps the most obvious feature of the sink is the display of small color swatches and image icons and corresponding lines of code pointing to those visual resources. gutters are also used to set breakpoints, facilitate code folding, and display range metrics. All of these features are described in more detail in later chapters.

< translation > the side column is used to pass information about your code. Perhaps the most obvious feature of the side column is that the visualization resources are displayed on the same line of your code with small color cards or small icons . Edge columns can also be used to set breakpoints, support code folding, and act as code-scoped indicators. All of these features will be described in detail in subsequent chapters .

Marker BarMarker Bar on the right side of the editor is the marker bar. The marker bar is used to indicate the location of important rows in the source file. For example, the tag bar highlights warnings and compile-time errors in Java or XML files. the tag bar also displays uncommitted changes, search results, and the location of the bookmark. the marker bar does not scroll like a sink; instead, the color scale on the marker bar is positioned relative to the length of the file. Clicking the colored tick in the tag bar immediately jumps to that location in the file. Now click on the scale of some colors and practice using the marker bar.

< translation >the right side of the editor is the marker bar. The marker bar is used to indicate the location of important rows in your resource file. For example, when your Java XML or file appears with a warning message or a compilation error, the marker bar highlights the information. The right column also displays uncommitted changes, the results of the search, and the location of the bookmark. The tab bar does not scroll like an edge column, instead, the color tag on the tab bar is relative to the length of the file. Clicking on the color tag in the tab bar will immediately jump to the location of the file. Now practice using the tab bar by clicking on some colored markers.

tool Buttonstool Buttons you have seen the Project tool window, which is displayed by default in the left pane. to see a list of all tool windows, choose View from the main menu bar. Tool window. now look carefully at the left, right, and bottom margins of the IDE. There you will find many tool windows corresponding to the tool buttons. Note that some of these tool buttons are also labeled with a number, with the Alt (CMD on MAC) key used to open/close the corresponding tool window for the tool button. Try tapping the tool button to practice this skill. also practice using keyboard shortcuts ALT + 1 | CMD + 1,alt + 2 | CMD + 2,alt + 3 | CMD + 3 and so on to toggle the tool window open/close.

< translation > You should have seen the default display in the left panel of the Project tool window. You can view all the tool windows by clicking on the "view> tool" on the main menu. Now you can take a closer look at the left, right and bottom of the IDE. You will find the tool button corresponding to the window. Note that there are some tool buttons followed by a number that combines the ALT key (the cmd on Apple) key to open/close the corresponding tool window. Try tapping these tool buttons to practice this skill . Use keyboard shortcuts ALT + 1 at the same time | CMD + 1,alt + 2 | CMD + 2,alt + 3 | CMD + 3 Open/Close tool window

when the tool window is open, the corresponding tool button is dark gray, indicating that it is depressed. Note that the tool button is located in the corner of the edge. For example, the default position of the Project tool button is the top corner of the left margin, and the Favorites tool button defaults to the lower corner of the left margin.

< translation >When a tool window is open, the corresponding tool button is dark gray, indicating that it cannot be pressed. Notice the tool button at the corner of the edge. For example, the default location of the item is in the upper-left corner, and the default location of the collection is in the lower-left corner.

The side pane (left, right, right) can share up to two tool windows. to see how to share the side pane, open the Favorites and Project Tools window. Note that the Favorites and Items tool buttons are located diagonally on the same margin. trying to share the same tool buttons between two tool windows in the same corner of the side pane will not work. For example, the project and Structure tool Windows cannot be displayed at the same time, at least not in the default configuration of Android Studio.

< translation > The sidebar (left, bottom, right) can be shared by two tool windows at the same time. Also open the Favotites and Engineering tools window to see how the sidebar is shared . As you can see, the Favorites and Items tool windows are located in the same studio window that cannot be displayed at the same time-at least not on the default configuration of Android studio that appears in a side pane window.

Default LayoutDefault Layout do not confuse the default layout in Android Studio with the layout in the Android SDK. the default layout is a specific set of tool windows that are clustered around the editor. Android Studio is configured with the default layout and displays the Project tool window in the left pane. This is the layout previously shown in Figure 2-1.

< translation > Don't confuse the default layout in Android Studio with the layout in Android's SDK. The default layout is a specific set of tool windows that are clustered around the editor . After the Android studio opens, configure a default layout that displays the Project tool window on the left. The previous layout is shown in 2-1.

Let's take a look at the Window menu in the main menu bar. the first two menu items are save current layout as default and restore default layout. The Restore default layout action is usually used when the IDE becomes too crowded, or you just want to clear the board and return to the familiar layout. You can also customize your default layout by opening and closing any tool window you like, resizing and/or repositioning the default layout, and then setting the new layout as the default layout by selecting Save current layout as default.

< translation >Let's take a look at the Window menu on the main menu. The first two menu items are stored
The current layout is the default (save the current layouts as the default layout) and restores the default layouts (restores the defaults). Restoring the default layout is usually used in the IDE window to become crowded, or you want to clean up the panel to restore it to your familiar layout . You can also set a new default layout by opening, closing, adjusting or repositioning your favorite windows, and then choosing to save the current layout as the default layout

. ----------------------------------------------- -

reposition tool button

As mentioned above, because the tool buttons are in the same corner, the project and Structure tool Windows cannot be displayed at the same time. However, you can move any tool button to any corner you want. drag and drop the Structure tool button to the bottom corner of the left margin. Now, use the keyboard shortcut ALT + 1 | Toggle the project and Structure Tool window CMD + 1 and ALT + 7 | CMD + 7 or click on the tool button. Because we moved the tool button to a relative corner, the project and Structure tool windows can now share the same side pane and display it simultaneously.

< translation > As mentioned earlier, the Engineering and Structure tool windows cannot be displayed at the same time because their corresponding tool buttons are located in the same corner . But you can move the tool button to the corner you want . Drag the Structure tool button. Drag to the bottom left corner now, use the keyboard shortcut ALT + 1 |. CMD + 1 Alt + 7 | | CMD + 7 or click the Tools button to open the Project and Structure Tool window as we move the two tool buttons to the opposite corner, all items and structures can be displayed simultaneously in the same panel window
. ------------------------------ -------------------

Navigation tool WindowNavigation tool Window This section discusses the tool windows that are specifically used for navigation: items, structures, favorites, to-dos, and commanders. Table 2-1 lists the features of each navigation tool window. the following chapters cover many other tool windows.

< translation > This section discusses the tool windows that are specifically used for navigation :. Items, structures, favorites, TODO and commanders table 2-1 lists the features of each of their navigation windows after the chapters will discuss many other tool windows

table 2-1. Navigation tool window


Table 2-1 Navigation tool windows


Project Tools WindowProject Tools Window We found that the Project tool window is the most useful navigation tool window, as it combines a wide range and relatively easy access. to understand the functionality and scope of the Project tool window, you may want to set the window's mode to project. There are three modes of Project, package and Android. By default, Android studio sets the mode to Android. Android and project are the most useful modes, although Android mode may hide some of your directories. the mode settings combo box is at 90 degrees and is adjacent to the Project tool button in the upper-left corner of the IDE. the Project Tools window provides a simple tree-shaped interface with files and nested directories that you can switch to. the Project Tools window gives you an overview of all the packages, directories, and files in your project. If you right-click (Ctrl-click the Mac) file in the Project tool window, a context menu appears. This context menu has three important menu items: The copy path, the file path, and the display in Resource manager. Click Copy Path to copy the absolute path of the operating system to the Clipboard. Click File path to display the path as a pile of directories, end with a file, and click any of these directories to open them in the operating system. Clicking Show in Explorer displays the file in a new window in the operating system. See figure 2-3. Click File path to display the path as a pile of directories, end with a file, and click any of these directories to open them in the operating system. Clicking Show in Explorer displays the file in a new window in the operating system. See figure 2-3. Click File path to display the path as a pile of directories, end with a file, and click any of these directories to open them in the operating system. Clicking Show in Explorer displays the file in a new window in the operating system. See figure 2-3.

< translation > We found that the Project tool window is a useful navigation tool window because it combines a limited width space with relatively easy access . To appreciate the utility of the Project tool window, you set the project to windowed mode. There are three types of projects in total; Project,packages and android.android Studio by default setting the mode to Android.android and project is a very useful mode, even though Android mode can hide some directories for you. The Mode settings combo box is adjacent to the upper-left corner of the IDE item button and is at a 90-degree angle. The Project Tools window provides a simple nested interface file and directory tree to facilitate your switching . The Project Tools window renders an overview of all the packages , directories, and files in your project. If you right-click in the Project Tools window, a context menu will be displayed. The absolute path of the operating system to the Clipboard. Click File path to display the directory stack in reverse order , and clicking on any of the directories will open them in the operating system. Clicking Show in Explorer will open a new window in your operating system to display the file.


Figure 2-3. Project Tools window
< translation > Figure 2-3 Project Tools window

Structure Tool windowStructure Tool windowThe Structure Tool window displays the hierarchy of elements in the file. when the editor displays a Java source file (such as Mainactivity.java), the Structure tool window displays an element tree (such as fields, methods, and inner classes). when the editor displays an XML file (such as Activity_main.xml), the Structure tool window displays an XML element tree. Clicking any element in the Structure tool window immediately moves the cursor to that element in the editor. The Structure Tool window is especially useful for navigating between elements in a large source file. Practice this skill by opening the Structure tool window and navigating between Mainactivity.java and activity_main.xml elements. See figure 2-4.

< translation >The Structure tool window is used to display the hierarchy of elements in a file. When the editor displays a source file for Java such as Mainactivity.java, the Structure tool window renders the elements in a tree form, such as fields, methods, and inner classes. When the editor displays XML files such as Activity_main.xml, the Structure tool window presents the XML elements in a tree structure. Click any element in the Structure tool window and the cursor will immediately move to that element in the editor. The Structure tool window is ideal for navigating elements in large source files. Practice this technique by opening the Structure tool window and navigating Mainactivity.java with elements in Activity_main.xml. As shown in 2-4.


Figure 2-4. Structure Tool window
< Figure 2-4 > Structure Tool window

Favorites Tool WindowFavorites Tool Window When you develop a feature (or debug a bug) in Android, you may create or modify several related files. a medium-complexity Android project may contain hundreds of separate files, so the ability to combine related files is really useful. The Favorites tool window contains favorites that allow you to logically group references into related files, otherwise these files may be in a completely different part of the project.

< translation > When developing a feature (or debug error) in Android, you may create or modify some related files . A medium-complexity Android project may contain hundreds of individual files, so the ability to have grouping-related files is very useful. The Favorites Tool window is a favorite for logically grouping related files that you will actually be in a completely different place in your project.

Make sure that the Mainactivity.java and Activity_main.xml files are loaded as tabs in the editor. now right-click any tab in the editor (CTRL + click on Mac) and choose Add All to Favorites from the context menu. in the Enter the new Favorites list Name field, enter Main, and then press OK. If the Favorites tool window is not open, use toggle Alt + 2 | To activate it CMD + 2. Expand the Favorites item named Main, and then double-click one of the files listed in to open/activate it.

< translation >Open the files in the Mainactivity.java and Activity_main.xml in the Editor tab. On either tab, right-click (Ctrl + Mac) and select Add all to Favorites from the context menu. Enter the master in the Enter new favorites name and click OK. If the Favorites folder is not open, Alt + 2 | CMD + Open. Expand the master in the list, and then double-click to open/Activate one of the files.

just like the Favorites window allows you to immediately navigate to any specific file or filegroup, bookmarks allow you to immediately navigate to any particular line in the file. Position the cursor on any line of Mainactivity.java. Now Press F11 (F3 on Mac). This action creates or deletes a bookmark in any source file, including an XML file. Also note the check mark in the sink and the black mark in the marker bar to indicate the new bookmark. to view the bookmark you just created, open the bookmark in the Favorites tool window.

< translation > just like a collection window allows you to immediately navigate to a specific file or filegroup , bookmarks allow you to quickly navigate to a specific line of a file . Place your cursor on any line of Mainactivity.java. Click on the F11 (press F3 under the Apple machine). This operation is to create or delete the resource file including the bookmark in the XML file. Observe the check mark of the Edge column and the black mark of the marker bar to indicate the new label . View the bookmark you just created by opening the bookmark in the Favorites tool window .

AttentionOn the computer, if F11 does not seem to respond, check to make sure
the F-lock key on the keyboard is activated.

< translation > Note:On the PC, if F11 is not responding, make sure that the F-lock key on your keyboard is active.

< translator Note: The Android studio has been upgraded, here F11 no effect of children's shoes can be viewed by clicking on the menu bar navigation? Bookmarks to view the label shortcut keys. >

breakpoints are used for debugging. Unlike bookmarks that can be set in any file, you need to be in a Java source file to set breakpoints. Open Mainactivity.java and click the gutter next to the following line of code:

< Break > is a breakpoint that is used for debugging. Unlike tags, which can be set in any file, breakpoints can only be set in a Java file. Open Mainactivity.java, and then click on the Edge column of the following line of code :

setContentView(R.layout.activity_main);


You'll notice that a red circle now occupies the gutter, and the line is highlighted in red. breakpoints can only be set on executable lines of code; An attempt to set a breakpoint on a comment line, for example, will not work. to view the newly created breakpoint, open the Breakpoints tree in the Favorites tool window. There are several interesting things you can do with breakpoints, and we'll discuss breakpoints in detail in the 12th chapter, which is dedicated to debugging.

< translation > you will find that a red circle appears in the Edge column , and that the entire line of code is highlighted in red, the breakpoint can only be set on the executable line of code ; For example, if you set a breakpoint on a comment line, there is no effect. Open the breakpoint in the Favorites tool window to see the breakpoint you just created. You can do a lot of interesting things with breakpoints , and in the 12th chapter, we'll discuss breakpoints for debugging.

Todo tool windowTodo tool window Todo certainly means to do. Todo is essentially a commentary that shows to programmers and their collaborators what remains to be done. Todo is written like a comment, starting with two forward slashes, all of the word todo and a space. For example:

< translation > Todo means of course it's something to do. Todo is essentially a matter for programmers and their collaborators to show that they have to do . Todo is written like a comment, starting with a double slash, then Todo uppercase, followed by a space. For example, create a Todo in Mainactivity.java and open the Todo tool window to view it. Click Todo in the Todo tool window to jump to Todo in the source code immediately. < translation > create a Todo in Mainactivity.java and open the Todo tool window to see it. Clicking on a todo in the Todo tool window immediately jumps to Todo in the source code.

//TODO inflate the layout here.






Commander Tool WindowCommander Tool Window The Commander Tool window is the navigation aid for the left and right panes. the functions of these panes are very similar to the project and Structure tool windows. The Commander Tool window differs from other navigation windows because it displays only one directory level at a time, rather than a nested directory tree. If you prefer Windows-style navigation, or if you find the Project tool window too overwhelming, the Commander Tool window can be a good navigation alternative.

< translation > The Commander Tool window is the navigation of the left and right panes. The functions of these panes are similar to the project and Structure Tools window. The Commander window differs from other navigation Windows in that it displays only one directory hierarchy in a time period , rather than a directory tree. If you prefer window-style navigation or if you think the Project tool window is too cumbersome, then the Commander Tool window may be a good navigation option.

< Translator Note: This book is published earlier, so some of the features of the Android studio have been changed, such as commanders have disappeared in the new version, so you can refer to children's shoes as appropriate. >

Chapter II: Overview of Android Studio (i) [Learn Android Studio Chinese Course]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.