Android SDK: Working with Android Studio
2023-1-26 10:9:0 Author: code.tutsplus.com(查看原文) 阅读量:12 收藏

Android app development has come a long way since its inception. In the early days, Eclipse was the preferred IDE to develop Android apps. You could use the Android Development plugin with Eclipse to develop Android apps.

However, as the industry matured Google started focusing on its own internal tool called Android Studio for app development. It is now the official and recommended tool for Android development. Things have improved a lot since the first version of Android Studio was launched and now it offers a huge set of features that will allow you to develop all kinds of apps.

In this tutorial, I will give you a simple overview of Android Studio and how you can start using it today.

Downloading, Installing and Updating Android Studio

Before you can use Android Studio, you will need to download and install it. You can head over to the official download page to get a copy. At the time of writing this post, the current version is nicknamed Electric Eel and its exact version number is 2022.1.1.

Android Studio Download PageAndroid Studio Download PageAndroid Studio Download Page

You will see a pop up once you click the download button. Accept the terms and conditions and then go ahead and download the file. It is around 950 MB in size for Windows and shouldn't take long to download. Once, you have downloaded the file, you can execute it to start the installation process.

Android Studio keeps releasing new versions with additional features and bug fixes. This means that your installed version will be outdated sooner or later. Android Studio will automatically let you know whenever updates to new tools and APIs are available.

A welcome window pops up whenever you start Android Studio and it contains a gear icon in the bottom left corner that you can click for any updates. Currently, I am on the Chipmunk version in Android Studio so I can download the last version Electric Eel as an update.

Check for Updates Context MenuCheck for Updates Context MenuCheck for Updates Context Menu

The update screen shows a list of new features and any incompatibility issues as you can see below. Click the Update and Restart button and you will be good to go.

Android Studio Update PopupAndroid Studio Update PopupAndroid Studio Update Popup

The update can take some time depending on your internet speed and system capabilities. After that, you can restart Android Studio and this time you will see a notification badge in the bottom-right corner telling us about available component updates.

Android Component UpdatesAndroid Component UpdatesAndroid Component Updates

In my case, this includes the Android Emulator and SDK platform tools. Click the link and then the Update Now button.

Android Studio Plugin UpdatesAndroid Studio Plugin UpdatesAndroid Studio Plugin Updates

You can also check for updates manually by navigating to Help > Check for Updates.

Android Studio Help Check UpdatesAndroid Studio Help Check UpdatesAndroid Studio Help Check Updates

Getting Familiar With the User Interface

Android Studio is a feature-rich and complicated application. It is natural to feel a bit intimated when you use it for the first time. In this section, I will give you a tour of the application interface so that you feel more comfortable while using Android Studio.

Whenever you open Android Studio, you should ideally see the menu bar at the top. The menu bar contains settings and options for anything that you might want to do in Android Studio.

Android Studio User InterfaceAndroid Studio User InterfaceAndroid Studio User Interface

For example, you can navigate to File > New in order to create a new project, directory, image asset or more. Similarly, you can find important code editing functionality like column selection mode and line duplication under the Edit menu.

Just below the menu bar, you should see the navigation bar. The navigation bar allows you to easily navigate through your project and quickly open any files that you want to edit or see.

Android Studio Navigation BarAndroid Studio Navigation BarAndroid Studio Navigation Bar

The right side of navigation bar contains some quick access buttons to perform actions like running or debugging an app, restarting an activity etc.

Android Studio Tool WindowsAndroid Studio Tool WindowsAndroid Studio Tool Windows

As you can see in the above image, Android Studio also contains an editor window where you can write new code or modify existing code. The look of editor window can change based on the file you are editing. In our case, we are editing the themes.xml file so it looks like a regular editor window. However, the editor window can also display visual information when you are editing layout files or drawables.

Another important feature of Android Studio is its tool window bar and the associated tool windows. You might have used applications where different sets of windows open based on your preferences. One such example is Photoshop where you can update the layout based on what you are working on like motion, painting, or photography. This is a common approach taken by many complicated applications to fit all relevant information in less space.

Android Studio takes a different approach to solve the problem of lack of space. Instead of giving you some preset perspectives or layout options to choose from, it will open up panels or tool windows whenever they are needed.

Android Studio Tool WindowsAndroid Studio Tool WindowsAndroid Studio Tool Windows

Tool windows are basically different panels that give you access to information or features relevant to a specific topic. The tools windows in the above image show you the project panel as well as the terminal panel. Running an application inside Android Studio can also open other tool windows such as the emulator.

The tool windows bar gives you quick access to common tool windows such as Project, Device Manager, Emulator, Profiler and Terminal etc. You can also see a list of all tool windows by navigating to View > Tool Windows.

  1. Project: The Project tool window gives you a brief overview of your project from different perspectives or viewpoints. You can also use it to navigate to a particular file or directory or to create new files or directories.
  2. Device Manager: The Device Manager tool window helps you in creating and managing AVDs also called Android Virtual Devices.
  3. Emulator: The Emulator tool window helps you see how your app will look and feel on a simulated android device using the Android Emulator.
  4. Build: The Build tool window displays the list of tasks that Gradle executes to build your app.
  5. Problems: The Problems tools window will display a list of problems that Android Studio has detected in your project. You can switch between tabs to see problems in the current file or project errors.

While Android Studio automatically hides and shows different panels or tool windows to you dynamically based on your requirements, you can also choose to show or hide different tool bars or view android studio code in different modes. All these options are available under View > Appearance.

Android Studio View Appearance MenuAndroid Studio View Appearance MenuAndroid Studio View Appearance Menu
  1. Presentation Mode: The editor expands to take up the whole screen and an increase in font size ensures that viewers can clearly see the text on screen. You can still access the main menu by hovering over the top of the screen.
  2. Distraction-Free Mode: The editor occupies the entire window in this mode and the main menu is accessible from the top.
  3. Full-Screen Mode: The main window occupies the entire screen and the main menu is accessible by hovering over the top of the screen.
  4. Zen Mode: This is a combination of Distraction-Free Mode and Full-Screen Mode where the editor occupies the entire window and the main menu is accessible by hovering over the top of the screen.

You can also hide all the tool bars like the menu bar, navigation bar, tool window bar and the status bar by toggling the tick mark against them.

Restoring the Menu Bar in Android Studio

Let's say you want to hide the Tool Window Bars that are present at the left, right and bottom of the Android Studio window. You can do so by navigating to View > Appearance > Tool Window Bars. Once they are hidden , you can navigate and click on the same menu option to bring them back.

The important thing to note here is the these settings are available from the Menu Bar. What if you actually hide the Menu Bar? Once the Menu Bar is hidden, you won't be able to navigate to View > Appearance > Main Menu.

In this case, you can get your main Menu Bar back by hitting the Shift key twice on your keyboard with Android Studio focused.

A window should pop up where you have to select the Actions tab at the top and then Enter Main Menu in the search bar. This should show you some toggle options as shown in the image below.

Turn on the toggle for View | Appearance: Main Menu to get your Menu Bar back.

Toggling Main Menu ViewToggling Main Menu ViewToggling Main Menu View

Final Thoughts

This tutorial covered the basics of Android Studio showing you how to download, install or update Android Studio. After that, we glanced over the Android Studio interface learning about different toolbars and windows. You should now have a brief idea of different available tool windows and how you can modify the layout to suit your needs.


文章来源: https://code.tutsplus.com/tutorials/android-sdk-working-with-android-studio--mobile-20203
如有侵权请联系:admin#unsafe.sh