Tips and tricks for Android Studio (Official document translator)

Source: Internet
Author: User
Tags java decompiler

This is the official document, the English good can go directly to the official documents to view, English is bad, we will see it, I translated the first technical article, because it is a English slag, technology is also slag, so recently learning English, try to translate, but translation has a bad place, we can point out, I will gradually improve in the future translation.
I will also try to translate a weekly English technical article, if you have a good learning English and translation skills, welcome to communicate with me.
Original link: http://developer.android.com/intl/zh-cn/sdk/installing/studio-tips.html

If you're unfamiliar with the interface between Android Studio and IntelliJ idea, just this article provides some tips to teach you some of the most common tricks you can make to increase your productivity.

High efficiency shortcut keys

Android Studio includes a number of features to help you program more efficiently, and this part contains features that help you work quickly and efficiently.

Smart Rendering

Using smart rendering, Android Studio shows a link to quick fix rendering errors. For example, if you add a button in the layout file that does not specify a width and height, Android Studio automatically displays the missing properties in the rendered message. Click these messages to add the missing properties to the layout.

Rendering Bitmap in debugging

When you are debugging, you can right-click on the bitmap variable in your app to invoke the bitmap view.
This extracts the data from the debugging process and displays the bitmap in the debugger.

Create a new file

You can quickly add new code and resource files by clicking the appropriate folder in the project panel by typing "ALT + Insert" (windows/linux), or by command + N (MAC). Depending on the directory type selected, Android Studio provides the appropriate file type to create.
For example, if you select a layout directory, type "ALT + Insert" (in Windows), select the layout resource file, open a dialog box, you can enter a file name (you can omit the. xml suffix), and then select the root node, and then switch to the design editor after editing. You can start designing layouts.

Output box Information filtering

When you examine build results, you can filter messages by message type to quickly find messages of interest.

Parent level settings

Activity A activity can be set up by creating a new activity in an Activity wizard. Set the parent-level return button to be automatically introduced in the Actionbar in your app. Therefore, the return button does not need to be specified manually in "Menu.xml".

Creating layouts

Android Studio provides an advanced layout editor that allows you to drag and drop controls into your layout. Edit the XML in the preview layout.
When you edit the text view, you can open the layout on the right side of the window preview panel settings. You can modify the preview by modifying various options on the top panel of the panel, including the preview device, theme, platform version, and so on, you can preview the layout on multiple devices at the same time, and you can drop the "preview all screen sizes" option from the " device " option.

You can toggle the graphics editor by tapping the design window at the bottom. When editing is a desin view, you can display and hide controls by clicking the Panel drag in the left window. Click the Display panel in the Designer right window to display the layout hierarchy and the list of properties for each view in the layout file.

Annotations

Android Studio provides Support-Annotations libraries to help you use annotations in your code, which are part of the support library, add dependencies to the library to decorate your code, help you catch bugs such as null pointer exceptions, resource type conflicts, and you can create enumeration annotations, for example, Check incoming parameter values from a defined set of constants, and more see code checks for improvements and callouts.

Java Class anti-compilation

When you don't find the source code, Android Studio allows you to see what's in the Java library.
Built-in anti-compilation makes it easy in Android Studio to right-click a class, method or field when you don't have a source file and choose to decompile. The anti-compilation code will appear. To adjust the settings for the decompile, select File > Settings > Other Settings > Java decompiler.

Debugging and performance enhancements

Android Studio provides debugging and performance enhancements, such as:
-Customize shortcut keys, change current shortcuts, select File > Settings > Keymap.
-Supports high resolution (retina) display on Widnows and Linux.
-Scratch files are fast prototyping files and will not create any project files.
Choose Tools > New Scratch file to open a Scratch files to quickly build and run code prototypes. Coupled with the code assistance of Android Studio, the Scratch file allows you to quickly run and support debug code updates for all file types. Code created by embedding the scripting language allows you to run code from a temporary file.

Dynamic templates

Dynamic templates allow you to enter code snippets to quickly insert and complete small pieces of code. Insert an abbreviation for the dynamic template input template Click the TAB key and insert the code snippet into the associated code in Android Studio.

For example, to enter newInstance an abbreviation, press the TAB key to insert a new initialization that includes the fragment of the parameter placeholder.

publicstaticnewInstance($args$) {    $nullChecks$    new Bundle();    $addArgs$    new $fragment$();    fragment.setArguments(args);    return fragment;}

Similarly, the input fbc inserts the findViewById type that will invoke the resource ID to be converted.

Display with the File > Settings > Editor > Live Templates menu options to support live templates and custom insert codes.

The practical work of IntelliJ coding based on

This section is just a small subset of code editing practices. You should consider using it when you are using Android Studio.

For a complete user document on the interface of IntelliJ idea (Android Studio is based on it) please refer to the IntelliJ ideas document.

Alt + Enter

Quickly fix bugs in code, powerful IntelliJ implements ALT + Enter fix errors (missing imports, variable assignments, missing references, etc.) where possible, if not, select the recommendations that are most likely to solve the problem.

Ctrl + D

CTRL + D is a powerful quick copy of code lines and fragments, just select the desired line or fragment and enter this shortcut (Ctrl + D).

Navigation Menu

If you are unfamiliar with some API classes, files or logos, the navigation menu can jump directly to a class of methods, fields, without needing you to search manually.

Scope check

The code snippet scope specifies a color that is easier to identify and locate, for example, you can set a range to determine the ID of the specified actionbar.

Injected language

Using the embedded language, Android Studio allows you to embed different languages in the workspace, this syntax extension, error highlighting, and encoding help for embedded languages. This is useful for inline checking of the values of regular expressions and validating XML.

Code Folding

This allows you to selectively hide and display some of the readable code. For example, resource expressions or inline code can be collapsed or hidden into one line, making the external structure easier to read.

Picture and color Previews

When you reference a picture or icon in your code, a preview of the image or icon is displayed at the edge of the code (depending on the density of the actual size) to help you verify the image or icon reference. Press the F1 key to display detailed information about the resource file in the preview picture or icon. For example dp , settings.

Quickly find documents

You can check the theme properties using View > Quick documentation (F1), view the inheritance hierarchy of topics, and resolve various property values.

If you call view > Quick documentation (usually bound to F1), view the Android:textappearancelarge theme property values. You will see the inheritance level of the topic, showing the various attribute parsing values.

Shortcut keys

The following table lists the commonly used keyboard shortcuts. The default shortcut keys can be modified in:File > Settings > Keymap(windows/linux). If you use Mac OS X, you must update to Mac OS X 10.5+ version to use shortcut keys: Android Studio > Preferences > Keymap.

Programming keyboard Commands
name shortcut Keys
Command Lookup CTRL + SHIFT + A
Engineering Quick Fix ALT + ENTER
Formatting code CTRL + ALT + L (Win) OPTION + CMD + L (MAC)
Display Document CTRL + Q (Win) F1 (MAC)
Show parameters for the selected method CTRL + P
Build method ALT + Insert (Win) CMD + N (MAC)
Jump to source code F4 (Win) CMD + down-arrow (MAC)
Delete Row CTRL + Y (Win) CMD + Backspace (MAC)
Search by symbol name CTRL + ALT + SHIFT + N (Win) OPTION + CMD + O (MAC)
Project and editor shortcut keys
name shortcut Keys
Build CTRL + F9 (Win) CMD + F9 (MAC)
Build and run SHIFT + F10 (Win) CTRL + R (MAC)
Toggle Item Visible ALT + 1 (Win) CMD + 1 (MAC)
Navigate to open Tabs ALT + Left-arrow; ALT + right-arrow (Win) CTRL + left-arrow; CTRL + right-arrow (MAC)

For more shortcut keys for full reference guide, see the IntelliJ idea document.

This article Tikitoo
The source of this article: Http://tikitoo.github.io/2016/05/10/android-studio-tips-and-tricks-zh
Non-commercial reprint please specify at the beginning 作者详细信息 and 本文出处 .

This article starts with my public number, share Android 开发 and 互联网内容 .
Number: AndroidMate
Public Number: 安卓同学

Tips and tricks for Android Studio (Official document translator)

Related Article

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.