Android Support Library Learning Primer

Source: Internet
Author: User
<span id="Label3"></p><span id="OSC_h1_1"><span id="OSC_h1_1"></span></span><span style="font-size: 18px;"><span style="font-size: 18px;">0. pre-article Gossip</span></span><p><p><span style="line-height: 22.5px; font-size: 12.5px;"></span> <span style="font-size: 14px; line-height: 22.5px;">as a native desktop application developer (VC, Delphi) to change the Android rookie, the abuse of heart is a myriad of things: install a development tool to download an SDK for a whole night; in the morning to work in the open Android Studio (as) , and went back to the water. it began to work; development tools a busy will forget you this developer, do not know how long after I give you a sentence: "to TMD gfw, I did not do anything, you look at it!" ”。 </span></p></p><p><p><span style="font-size: 14px; line-height: 22.5px;">For those of us who have been brainwashed by microsoft, Borland, and Sybase for many years, in addition to the development of tools, the biggest barrier in fact is the brain has been inherent in the way of thinking, often in the acceptance of the new concept is always habitual to compare with what has already been recognized, this is more than a new Comer consumes more time and energy. For example, This article to talk about the Android support library, has been my words too literally as the bottom of the system supporting libraries, in my side constantly appear, but never into my head. So after a lift over the wall, check the official website information, here try to get to the BOTTOM.</span></p></p><p><p><span style="font-size: 14px; line-height: 22.5px;">There are no shortcuts or tricks to really master the Android support Library. There is only one way to read the official API reference, one for a class to understand one Function. Let's make this an appetizer before you start tasting the "api reference" Feast.</span></p></p><span style="background-color: inherit;"><span style="background-color: inherit;"></span></span><span id="OSC_h1_2"><span id="OSC_h1_2"></span></span><span style="font-size: 18px; background-color: inherit;"><span style="font-size: 18px; background-color: inherit;">1. Support Library Introduction</span></span><p><p><span style="font-size: 14px;">In the official document (original:<span style="background-color: inherit;">http://developer.android.com/tools/support-library/index.html</span>) The <span style="background-color: inherit;">first sentence indicates the role of the support library: "the Android Support Library code package makes the latest features in the new version of the Android framework compatible with previous versions of the Android <span style="background-color: inherit;">framework</span> ." This means that the support library provides backwards compatibility for an escalating Android System. </span></span></p></p><p><p><span style="font-size: 14px;">The translation above is not straightforward, or a metaphor: Suppose Google releases a new version of the Android API provides a new feature: you only need to invoke a simple API function can be used in the application of the vehicle photos when the car automatically identify the brand, and vibrate to remind users, it is really cool. But it's frustrating that you're calling this API to write apps that don't even show up on older Android phones that are so diao that they can't be installed and Run. This is the support library, and the support library allows <strong>new API features</strong> to function properly on the <strong>specified version</strong> of ANDROID. (note the "new API features" and "specify versions" here, <span style="font-size: 14px; line-height: 21px;">when using support libary, first determine the two points: what new API features you want to use and which version of Android is supported to the Minimum.) </span>)</span></p></p><p><p><span style="font-size: 14px;">For the development of VC + +, Google's compatibility of this way looks too familiar. Each time a Visual Studio upgrade comes with a new version of the MFC library, it is important that you package the appropriate version of the MFC library at the same time to run in each version of Windows. <span style="font-size: 14px; line-height: 1.5;">just because Google does not directly through the Google API library to achieve this compatibility, but instead of a separate support library. </span></span></p></p><p><p><span style="line-height: 1.5; font-size: 14px;">The official documentation mentions that for application developers, depending on the version of the system supported by the application and the API functions used, it is best to include the appropriate support Libary in the Android project to use the new features, which will not only turn your Application's interface from poor D to white rich, More importantly, You can expand your user Base.</span></p></p><p><p><span style="line-height: 1.5; font-size: 14px;">For Android developers, due to the face of a variety of device types, high and low different system versions, so in a piece of Android development of small meat into the old bacon evolution process, can skillfully deal with compatibility issues is an indispensable basic skills. To do this, be aware of the API level at which each feature is added, and pay attention to the API level in the upper right corner when viewing the official manual API Reference.</span></p></p><p><p><span style="line-height: 1.5; font-size: 14px;"></span></p></p><p style="text-align: center"><p style="text-align: center"></p></p><p><p><span style="line-height: 1.5; font-size: 14px;"></span><br></p></p><p><p><span style="font-size: 14px; line-height: 1.5;">In addition, the following section will introduce the support Library features the original text read a few more Times.</span></p></p><span style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto; background-color: rgb(255, 255, 255);"><span style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto; background-color: rgb(255, 255, 255);"></span></span><span id="OSC_h1_3"><span id="OSC_h1_3"></span></span><span style="line-height: 1.5; font-size: 18px; background-color: inherit;"><span style="line-height: 1.5; font-size: 18px; background-color: inherit;">2. Support Library Features</span></span><p><p><span style="font-size: 14px;">The support library is actually a combination of multiple libraries (jar packages), which has to say that its jar package name is more confusing, for beginners like me, it is easy to form the wrong "take it for granted" Judgment. For example, the following</span></p></p><pre class="brush:java;toolbar: true; auto-links: false;"><pre class="brush:java;toolbar: true; auto-links: false;">com.android.support:support-v4:21.0.0</pre></pre><p><p><span style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto; background-color: rgb(255, 255, 255);">I was careless in the beginning of the V4 as the version number (21.0.0 is the real version number), so always confusing what the situation to choose V4 version, What is the choice of V7 version? Is there v5, v6? In fact, V4 and V7 are different library names in the support Library. The V4 in the package name is not a version number, but it shows its uncommon origins: "my birth is to illuminate Android1.6 (<span style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; background-color: rgb(255, 255, 255);">API level 4</span>) users!" ”</span></p></p><p><p><span style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto; background-color: rgb(255, 255, 255);">The 1th edition of the Support library (released in March 2011) contains only the V4 library, and the subsequent version is constantly perfecting the V4 Library. Until the 13th edition of 2 years (May 2013), The V7 library (v7 is actually a combination of libraries) was added for compatibility with API Level 7 (android2.1). The time has Android4.3 (API level 18).</span><br></p></p><p><p><span style="font-size: 14px;">as Google continues to address version compatibility issues in order to improve the user experience, the support library is becoming larger. In addition to the two most common libraries of V4 and v7, the support library features contains 10 other libraries (do you know if the support library will have an end point in the future?). ), the functional characteristics of each library</span>are discussed in detail in the original text (http://developer.android.com/tools/support-library/features.html<span style="font-size: 14px;">). here, just list the library names contained in the support Library. </span></p></p> <ul> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">V4 Support Library</span></p></li></li> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">Multidex Support Library</span></p></li></li> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">V7 Support Libraries (note is plural, therefore a set of libraries)</span></p></li></li> <ul> <ul> <li> <p> <span style="line-height:1.5; font-size:14px; background-color:inherit;">v7 AppCompat Library (the most common) </span> </p> </li> <li> <p> <span style="line-height:1.5; font-size:14px; background-color:inherit;" v7 cardview library < span> </span></p> </li> <li> <p> <span style="line-height:1.5; font-size:14px; background-color:inherit; >v7 GridLayout library </span> </p> </li> <li> <p> <span style= " line-height:1.5; font-size:14px; background-color:inherit;>v7 mediarouter Library </span> </p> </li> <li> <p> <span style="line-height:1.5; font-size:14px; background-color:inherit;">v7 Palette Library </span> </p> </li> <li> <p> <span style="line-height:1.5; font-size:14px; background-color:inherit;">v7 Recyclerview Library </span> </p> </li> <li> <p> <span style="line-height:1.5; font-size:14px; background-color:inherit;">V7 Preference support Library </span> </p> </li> </ul> </ul> </ul> <ul> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">V8 Support Library</span></p></li></li> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">V13 Support Library</span></p></li></li> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">V14 Preference Support Library</span></p></li></li> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">V17 Preference support Library for TV</span></p></li></li> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">V17 Leanback Library</span></p></li></li> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">Annotations Support Library</span></p></li></li> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">Design Support Library</span></p></li></li> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">Custom Tabs Support Library</span></p></li></li> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">Percent Support Library</span></p></li></li> <li><li><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">APP recommendation Support Library for TV</span></p></li></li> </ul><p><p><span style="line-height: 1.5; font-size: 14px; background-color: inherit;">Because V4 support Library and V7 support Librarys mainly involve program components, new user Interface effects, network connections and other basic changes, so we usually more commonly used to.</span></p></p><span id="OSC_h1_4"><span id="OSC_h1_4"></span></span><span style="font-size: 18px;"><span style="font-size: 18px;">3. Installation of the support library</span></span><p><p><span style="font-size: 14px;">if you're using Android Studio (a rookie like me must have chosen as, you've used eclipse to develop an Android veteran, please fly through this section), the support library is easy to install and Use. Just open the SDK Manager, click a few clicks, and add a few lines of Code. No Letter please see:</span></p></p><span id="OSC_h2_5"><span id="OSC_h2_5"></span></span><span style="font-size: 16px;"><span style="font-size: 16px;">3.1 Downloads</span></span><p><p><span style="font-size: 14px;">Open SDK Manager:</span></p></p><p><p><span style="font-size: 14px;"></span></p></p><p style="text-align: center"><p style="text-align: center"></p></p><p><p><span style="font-size: 14px;">Official website specifically indicates that if you use Android Studio, Select and install</span> <span style="font-size: 14px;">Android Support Repository, no need to select Android support Library. </span><br></p></p><span id="OSC_h2_6"><span id="OSC_h2_6"></span></span><span style="font-size: 16px; background-color: inherit;"><span style="font-size: 16px; background-color: inherit;">3.2 Add support Librarys to the program</span></span><p><p><span style="background-color: inherit;"><span style="font-size: 14px; background-color: inherit;">In the official website, according to the two libraries with resources and without resources, the different usage methods are introduced, in fact, only for Eclipse. If you use Android Studio, use the same method: just open the Build.gradle file and add the following code (take The V4 library as an example):</span></span></p></p><pre class="brush:java;toolbar: true; auto-links: false;"><pre class="brush:java;toolbar: true; auto-links: false;">Dependencies {... Compile "com.android.support:support-v4:18.0.+"}</pre></pre><p><p><span style="background-color: inherit;"><span style="font-size: 14px; background-color: inherit;">The rest of the matter is to use the classes you need in your Code.</span></span></p></p><p><p><span style="font-size: 14px;"><strong>official Reminder:</strong> after you have included the support library in your application, it is strongly recommended that you use the Proguard tool to optimize the release package before you publish the Program. In addition to the ability to protect your source code is not used by others to get the anti-compilation tool, and it will be referenced by your program in the Third-party Library is not used in the class are removed, so that your application to keep as small as possible, do not forget that the storage on the phone is an inch of gold ah!</span></p></p><span id="OSC_h2_7"><span id="OSC_h2_7"></span></span><span style="font-size: 16px; background-color: inherit;"><span style="font-size: 16px; background-color: inherit;">3.3 Modify manifest file</span></span><p><p><span style="background-color: inherit;"><span style="font-size: 14px; background-color: inherit;">now that You've used the support Library, your app can go all the time in one step, compatible with more <span style="background-color: inherit;">system</span> versions. That is to modify the version declaration in the manifest File. Open the Manifest.xml file, find the <span style="background-color: inherit;">android:minsdkversion, and</span> change it low enough. </span></span></p></p><pre class="brush:java;toolbar: true; auto-links: false;"><pre class="brush:java;toolbar: true; auto-links: false;"><USES-SDK android:minsdkversion= "7" android:targetsdkversion= "/>"</pre></pre><p><p><span style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto; background-color: rgb(255, 255, 255);"><span style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto; background-color: rgb(255, 255, 255);">You might ask, "who did I change manifest.xml to?" ”。 yes, It's really not for people to See. The above <span style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; background-color: rgb(255, 255, 255);">Manifest</span>. Xml tells Google Play (google's official app Store) that your program can be installed on devices on Android 2.1 (API 7) version, below this version, I guess it should not be installed. Because I didn't use Google Play (with a flush of blush), the domestic software app Store seemed to have no version hint, and I only saw Apple's App store for version Judgment.</span></span></p></p><span id="OSC_h1_8"><span id="OSC_h1_8"></span></span><span style="font-family: 微软雅黑; font-size: 18px; line-height: 21px; widows: auto; background-color: rgb(255, 255, 255);"><span style="font-family: 微软雅黑; font-size: 18px; line-height: 21px; widows: auto; background-color: rgb(255, 255, 255);">4. Concluding Remarks</span></span><p><p><span style="font-family: 微软雅黑; font-size: 14px; line-height: 21px; widows: auto; background-color: rgb(255, 255, 255);">in Enterprise applications, in addition to the more specialized native desktop applications, most business systems have migrated to the b/s architecture of the web, with the popularization of mobile internet, a large number of applications will be migrated to the mobile phone, which will include the original small number of desktop Applications. Native desktop applications have a smaller living space, and in turn there are a lot of new mobile application requirements, and new opportunities are slowly coming. Native Desktop program developers, in order not to be eliminated by this era, master the development of Android as soon as Possible. The road long its repair far xi, I can only keep tossing and unloading. </span><span style="font-family: 微软雅黑; font-size: 18px; line-height: 21px; widows: auto; background-color: rgb(255, 255, 255);">    </span></p></p><p><p><br></p></p><p><p>Android Support Library Learning Primer</p></p></span>

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.