Teach my Apprentice Introduction to Android development (IV)

Source: Internet
Author: User

Knowledge points in this issue:
    • A brief introduction to the two most commonly used layouts
    • Use third-party libraries in our app
    • Common shortcut keys for Android Studio
One, two commonly used layout 1. LinearLayout Linear layout

Linear layout, can be displayed vertically or horizontally, set LinearLayout display Mode property is orientation, with vertical and horizontal

If not set, you can display a control, if the layout put more than one control, it is not possible to display the corresponding control, because the layout does not know how to display the control

2.RealtiveLayout Relative layout

Realtivelayout, depending on the control to control the display of the place, unique is the Margin_xx property, this online should have the corresponding information, here not much to say

Ii. use of third-party libraries

There are many easy-to-use open source libraries (third party libraries), which can save us a lot of time in development, so how do we go about using them? Look down, please.

1. Two ways to import third-party libraries

Before using a third-party library, we have to import the third library into our project before we can use

The third library can be divided into two categories, one of which is large (or officially developed), and the other is a personal developer.

For example, if you read my blog, you should know recyclerview this control, this recyclerview is actually a reinforced version of the ListView, is Google's official in the ListView based on a third-party library, We have to import it into our project when we use it,

There are two ways of importing:

First open file, go to project stucture Click the Add button (the plus sign), then select the appropriate third-party library to add to our project

The second is to write the relevant code in the Gradle file.

As you can see in the picture, there are two build.gradle files, so which one should we modify?

Modify the one in the app directory

I use the project mode view in the picture, if you use the default (that is, Android mode), you can see more obvious

We go into the Gradle file and we can see the third-party libraries we've imported

In fact, the essence of both is to add code on the Gradle file

PS: Here to mention, the official direct input compile XXX will be able to import those official third-party library, if it is a personal developer, they generally send the third library in a jitpack site, when we import, We'll have to add that website to our Gradle file (here's gradle, the other one mentioned earlier Gradle)

maven { url ‘https://jitpack.io‘ }

Then import the relevant third-party package and use it

In general, the authors of third-party libraries write the relevant usage instructions on his GitHub project, and we can use them against the instructions they write if we don't know how to use them.

Example:

Here I take the textview of a typewriter effect I recently developed to illustrate

Https://github.com/Stars-One/SuperTextView

Go to my that project GitHub, can see there are instructions for use, I now only write the Chinese version of the use of the document, can be used to view in the document, use should be very simple, I will not say more

Here is a demonstration, import my library

Can be seen from the above picture, how to import the

The two Build.gradle,app is written compile ‘com.github.Stars-One:SuperTextView:v1.1‘

The other one is addingmaven { url ‘https://jitpack.io‘ }

Don't forget to click Sync to Refactor!!

Third, the common shortcut keys for Android Studio

Before, after installing Android studio, because not accustomed to the keyboard shortcuts on Android studio, I changed the shortcuts of Android studio to the shortcut keys in Eclipse, now feel that Such changes may later enter the company AH what will not be used to (the company is sure to use the default shortcut key,), and, sometimes find a shortcut key, most of the online information is said the default of the Android studio shortcut keys, very inconvenient, In this way, we also adapt to the trend, and began to get used to the common shortcuts of Android studio

Ctrl +alt +e Findviewbyid

Alt+insert generate code (such as Get,set method, constructor, etc.)

Ctrl+shift+space Auto-Complete code

CTRL + Space Code hints

Ctrl+p Method Parameter Hints

Ctrl +o Replication method

Ctrl+i interface Replication

ALT + ENTER import package, auto fix

Ctrl+j Code template (shortcut code)

ctrl+/or ctrl+shift+/Comments (//or/*...*/)

Ctrl+b quickly open the class or method at the cursor (CRTL + mouse click can also)

Ctrl+alt+t can wrap code inside a piece, such as Try/catch

Ps:ctrl + Space This in my computer and Sogou Input Method switch in English shortcut keys conflict, very silent,ctrl+shift+space This is similar to this, make use of it

Teach my Apprentice about Android development (iv)

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.