Press enter to see results or esc to cancel.

Elements of Android Studio IDE- Code Editor

Share this
()

As we could begin to see, Android Studio is a very powerful development environment, rich in useful features whose use we must understand well to exploit them to the fullest. So what we’re going to do in this lesson (Elements of Android Studio IDE- Code Editor), is to analyze the most important areas and components of this IDE, including Features and common configurations.

When Android Studio is launched, the welcome screen is displayed, unless you have previously left the environment without closing the project we were working on, in which case the latter is reopened.

Android studio first screen
Android studio first screen

When we want to close a project we are working on, all we have to do is click on the File menu and then select the Close Project option.

android studio close project
android studio close project

Topic: Lesson 7 – Anatomy of Android Studio Environment – Settings, Features.

In the welcome screen, on the left, a list of recent projects is displayed, while in the central part there is a list of options, including those to open an existing Android project, create a new project, import a project from another platform. The Configure item, on the other hand, refers to another screen that provides various other options, including the management of the SDK Manager as we saw in the previous lesson when we created our First Android project.

android studio configure screen
android studio configure screen

Anatomy of Android Studio Environment.

When we create a new project (or open an existing one) the main Android Studio window is displayed. If we open multiple projects simultaneously, each will have its own window associated with it. The configuration of this window depends on which tools and panels the user decides to display, but is typically similar to the following:

android studio overview (Anatomy) - Home Screen

The fundamental elements are:

1. Menu Bar

The menu bar, which contains a series of menus with different features. This bar provides you with the window to find the majority of Android studio essential functions. Menus in this bar include File, Edit, View, Navigation, Code, Analyze, etc.

android studio menu bar
android studio menu bar

2. Navigation bar

The navigation bar, which allows you to easily move between the files and folders of the project. It serves as a control point to link the user to the project and open files for editing.

android studio navigation bar
android studio navigation bar

3. The Documents tabs

Android editor document tab
Android editor document tab

The documents tab provides easy navigation to all the opened documents that uses android studio editor. In Android Studio it is possible to keep several documents open at the same time and each of them is assigned a tab with the name of the corresponding document. To switch from one document to another, just click on the corresponding tab.

4. Toolbar

The toolbar, which provides shortcuts for the most frequently performed operations. There are clickable icons that perform specific application functions such as running your app, Debugging, App Profiling, Synchronise project with Gradle files.

android studio toolbar
android studio toolbar

5. The side navigation bar

android studio side navigation bar gutter
android studio side navigation bar gutter

Android Studio side navigation bar, also known as gutter, this bar is used to display other information and controls. Some typical elements are markers for breakpoints, bookmarks, code line numbers, etc.

6. Code Editor Window

The editor window, which shows the contents of the file you are working on if it is a code file, or displays the graphical interface if it is a layout file.

android studio java code editor
android studio java code editor

7. The validation sidebar

android studio editor validation sidebar
android studio editor validation sidebar

The Validation Sidebar is a very important feature of Android Studio that allows you to analyze the code in real-time. This means that while we write our code the Android code editor analyzes it, promptly reporting syntax errors or other warnings. In the first image of this lesson you can see the declaration of an Int type test variable without closing the two points and in fact, if we pass the mouse on the red line of the validation bar a popup appears highlighting this error.

Android studio Validation Sidebar allows you to analyze the code in real-time. Click To Tweet

8. Project Windows

The project window, which provides a hierarchical view of the project structure and the elements it contains. Looking at the Project window we can see the presence of numerous files and folders that make up our project.

Android studio Project window
Android studio Project window

9. Status bar

android studio editor status bar
android studio status bar

Android Studio status bar provides useful information on the active editing session. This information includes the current cursor position in terms of line and character (7:9 in the previous image), the type of line separator, the file encoding format (UTF-8 in our example), memory heap size (this displays the allocated and used memory) and many more.

10. Tool window bar

The tool window bar runs around the outside of the IDE window and contains the buttons that allow you to expand or collapse individual tool windows.

Android Studio Code editor

Let’s analyze the fundamental characteristics of Android Studio Code editor. In android app development, it is necessary to write a lot of code, so a fundamental aspect of any development environment is the code editor. Modern code editors provide several additional features compared to classic ones in order to increase developer productivity, for example by making it easier to navigate within the code or by highlighting programming errors in real-time.

Features of Android Studio Code editor

Android studio code editor appears in the main window of the development environment when a file containing code (XML, Java, etc.) is opened. For example, if we open the MainActivity.java file in the example application seen in the previous lessons, here’s what we see

android studio code editor
android studio code editor

Some of the features you can find in code editors are The documents tab, Validation Sidebar, and Side navigation bar.

Android Studio code editor also offers an advanced real-time code completion feature. As we write our code the editor analyzes it and gives suggestions about the best way to complete it through a panel with a list of suggestions.

Here’s what appears if we start writing obj

android studio real-time code completion
android studio real-time code completion

If none of the suggestions displayed is correct, simply continue writing to refine them more appropriately. To select the first suggestion just click on Enter or Tab, to select another from the list, scroll with the directional arrows to select it and then click on Enter or Tab.

Another useful feature is the indication of the parameters required by a method. To get this information just position the cursor between the brackets of a method call and click on the key combination Ctrl + P

android studio indication of the parameters
android studio indication of the parameters

Android Studio Code Folding Feature

When the code is very long it is advisable to format it and organize it so that it is not difficult to navigate inside it. Android Studio comes to our aid once again by providing the source code folding feature. In fact in the gutter bar, in correspondence of the various methods, markers appear operating on which it is possible to compress (or expand) the code.

android studio code folding feature
android studio code folding feature

In general, the Android Studio code editor performs automatic formatting of the code in terms of indentation, spacing, and nesting of the instructions. In situations where the lines of code need to be reformatted, for example after copying and pasting a piece of code, you can use a feature that automatically performs this operation. To use it just select the portion of the code concerned and use the key combination Ctrl + Alt + L.

The various features seen in this lesson and many others can be managed through the Settings dialog box that appears by clicking on the File menu on the Settings item

android studio settings menu
android studio settings menu

 

Topic: Lesson 7 – Anatomy of Android Studio Environment – Settings, Features.

Let’s briefly explain the contents of some important folders and the function of some files:

Java

It contains files with java extensions that characterize our application. In our example, there is a file called MainActivity.java (in the process of creating the project I named the main activity in this way).

Java, This is the source file that allows you to manage the activity and within which we can write the code that regulates the behavior of our application. Click To Tweet

res

It contains all the resources used by the application and the files related to the graphical interfaces. In addition, there are other important sub-folders, such as layout and values. In the layout subfolder, there is the activity_main.xml file that defines the user interface of our activity.

Inside this file initially only the following code is present and any subsequent modification to the user interface will be reported in it

android studio xml and designer view
android studio xml and designer view

AndroidManifest.xml

This is the application manifest file. In it, you can specify the permissions related to the same and other important aspects. This is the initial content of the file

android manifest file
android manifest file

As is evident, the Android manifest file contains detailed information about the application: it defines the name of the package, the image representing the application on the device (icon), the name of the application (label), the name of the activities present in the application (in our case only one, Main Activity).

Within the definition of the activity MainActivity, we can see an element called intent-filter – It serves to indicate that this activity is the starting point of the application (action) and that it can be started through the launcher of the device on which it is in use (category).

In addition to these elements, Android Studio includes various other windows which, when enabled, are displayed on the sides of the main window and which we will discover using the environment.

Topic: Lesson 7 – Anatomy of Android Studio Environment – Settings, Features.

Android Studio keyboard shortcuts

Obviously, Android Studio offers a large number of keyboard shortcuts. A list of these can be viewed by clicking the Help menu on the Keymap Reference item which will open a link to your browser and download a pdf file containing all the latest android Studio shortcuts for both Windows and Apple Users.android studio keyboard shortcut

android studio keyboard shortcut

Some of the functions you will find shortcuts for are: Editing, Navigation, usage search, Debugging, Search and Replace, Refactoring, compile and run, etc.

android keyboard shortcut
android keyboard shortcut

It is also possible to change the theme of the development environment by accessing the File menu and selecting the Settings option. In the window that appears, just select the item Appearance and choose the theme from those available.

Change the theme of Android Studio

For example, this is the Darcula theme:

Darcula theme android studio
Darcula theme android studio

How useful was this Lesson?

Click on a star to rate it!

Average rating / 5. Vote count:

Be the first to rate this post.!

As you found this post useful...

Follow us on social media!

We are sorry that this lesson was not useful for you!

Let us improve this lesson!

Tell us how we can improve this lesson?

Share this