Android Support Library Introduction

Source: Internet
Author: User
Tags api manual

We know that Android since the first generation release, its version update iteration speed can be said to be very fast, but Android is a mobile operating system, is facing all users, not an industry-specific system, which is to require this system in frequent updates, The large-scale system that already exists must be enabled to be compatible with the new version. To do this is to do the API compatibility problem, the old interface is discarded, but in the new system version must also be able to use, the new interface is not available on the old version, but provides excellent features, developers want to use on the old system platform, these problems are Android development problems, So how do you solve these problems? Google introduced the support library this thing. This article on my development experience to talk about the support Library, aimed at introducing this thing to the novice. This writing, borrowed from Google's official support library introduction, and added some of their own understanding, if there are deviations, it is unavoidable, I hope you even correct.
Google Support Library Introduction address:
Https://developer.android.com/topic/libraries/support-library/index.html
Chinese version of (enthusiastic netizen translator):
http://blog.csdn.net/crazybigfish/article/details/18363351
Also, if you download the SDK for Android, the support library's jar and source path are:

<YOURSDKDIR>/extras/android/support/

The content is probably like this:

Overview

The Android Support library provides many features that are not compiled into the framework, which provide many new features that are backwards compatible, provide useful UI elements that are not available in the framework, and provide tools that many apps can use. In many cases, some features are valuable to developers with many apps, but these features are not appropriate if they are included in the framework. For example, an app might need a feature for a particular usage scenario, not a common scenario feature, and if you put it in the framework, it would make the framework more and more bloated and could cause the API to become cluttered, These are fatal to an operating system.
But these requirements, Android can not be regardless of the question, so Android provides a series of support packages to support these requirements, the presentation of these support packages is a jar package, app developers simply add this jar package to the app project to use the features and APIs. The Support library provides the following basic features:
1. Version backward compatible: Ensure that the new version of the features can still be run on older versions
2. UI elements that implement the Android layout mode
3. Support for different forms of elements
4. A variety of tool method functions
The Android Support library offers so many features, so Google suggests that all app developers should be developing using the service library. Let's comb through these features one by one:

Backwards compatible

The support library allows apps to use the new Android version on older versions of Android. For example, if you develop an app that uses the Android 5.0 material design, the entire app's interface style is a material design style and looks beautiful! This app has no problem running on 5.0,6.0, but once it runs on a system up to 4.4, all the material design styles are gone, and it looks ugly .... What to do? The basic reason is that the version before 4.4 does not support material design this thing!!! But the AppCompat library of the support library can be solved, as long as your app contains the library, and you can use the material design theme in his material design on the very old version of Android! Isn't it simple, yes! The simple reason is that Google has done the complex things for you, you just have to use them. This way, your app can keep the user experience consistent across many Android versions!
In some cases, the support library's behavior is still subject to the specific Android platform, as it ultimately requires the use of the system's interface. In these cases, if an app invokes a method of the support library, the behavior of this method depends on the version of the platform the app is running on. If the framework provides the necessary methods for this approach, the support library calls this method to do the work, and if the app is running on an older version and the framework does not provide the necessary interfaces, then the support The library will attempt to invoke its own internal interface to do the job or, worst of all, it will not respond to a call. But it will never cause the app to crash or appear strangely bug! This is when the support library's behavior is unpredictable, and the worst outcome is that there is no result, and never a wrong result. At the same time the app should not judge the version of the system platform itself, this work should be done by the support library itself, the class name in Compat end will automatically do such judgments, such as Activitycompat this class. This part of the interface when used, you need to carefully review the relevant API documentation instructions.
In addition, it is important that the support library also provides a complete, completely separate interface class that has no relationship to the framework of the system platform and behaves the same on any platform. This part of the interface can be used with confidence!
Again, in both cases, the app should not take the initiative to check the version of the system platform, this part of the work should be done within the support library.

Supports common layout mode

The support library provides UI elements that are not affected by the Android framework, for example, the Android Support library provides an additional layout class: Drawerlayout. These classes are designed to follow the basic practice principles of Android system design, such as the design library, which follows the all-in-one principle of the Android 5.0, so that the library behaves the same on many Android versions.
If you use the support library, you can avoid the dilemma of repeating wheel-building. If your app has a specific UI requirement, you can use these out-of-the-box code that provides the user's familiar interface style and design, which is important to ensure the user experience consistency of the app. These classes can also help you build an app that looks like a part of the Android ecosystem, because these libraries are designed to be completely Android-designed philosophy! For example, many apps need to show a list of any length, and the information in this list can be displayed quickly and smoothly when the information changes, and the elements in this list may be mail, contacts, music albums, etc. These apps can use the Recyclerview in the support library to display the list. This approach allows developers to build their own classes without starting from 0, and ensures that the user experience in our app is consistent with the experience of the system platform! These are important principles in the HMI design!

Provide different types of features

The Android SDK provides a library of many elements, such as TVs and wearables, an app that relies on a suitable support library to provide multi-platform unified functionality and can provide content for devices that exist on external monitors, speakers, and elsewhere.

Common tools

The Android Support Library also offers a number of backwards compatible multiplatform, multi-Version tool class methods. Apps can use these tool classes to provide a consistent user experience across multiple versions of the Android system. For example, the permissions method provided by the support library will depend on the specific version of the system, and if it runs on a version of the model that supports dynamic runtime permissions checking (6.0+), then this method will be run to pop up the corresponding dialog to ask the user for the required permissions If it is running on a version that does not support dynamic permissions, this method will ensure that the required permissions are granted when the app is installed.

The features provided

The Android Support Library package contains a list of libraries that can be included in your app, each of which provides a specific set of Android version ranges and features.
Next we will describe the features of these libraries to help you decide which support libraries to use. In general, Google suggests that developers need to include both V4 support and V7 AppCompat, as both libraries provide a wide range of Android versions and APIs that conform to the Android UI design pattern.

V4 Support Library

The reason this library is called the V4 Support Library is that it runs on the Android 1.6 (API 4) version, and it offers a very rich API compared to other libraries, including support for app components, user interface features, device accessibility, data processing, network linking and programming tools. Here we briefly describe the classes contained in this library:

App components
    1. The fragment provides a flexible interface design, especially for UI designs where the interface changes frequently or the screen is large (such as a tablet device). It is important to note that if you use the fragment in the V4 package, even if your app is running on Android 3.0, your app still uses the fragment class in the V4 package instead of fragment in the system framework.
    2. Notificationcompat adds a notification feature for rich information content, the notification in Android is divided into regular notifications and rich text notifications, and general notifications look like this:

      Rich text notifications such as:

      For notification Introduction please see:
      Https://developer.android.com/guide/topics/ui/notifiers/notifications.html
    3. Localbroadcastmanager This is a very useful class that allows our app to broadcast internally without sending a global broadcast through sendbroadcast, especially if security requirements are high.
User interface
    1. Viewpager adds a viewgroup to manage the layout of the sub-view, allowing the user the flexibility to use the swipe of the finger to toggle the screen
    2. Pagertitlestrip This is a non-interactive, can be used to display the current, the next and the previous page of the indicator, generally just for display, usually as a sub-view in the Viewpager.
    3. Pagertabstrip This is a navigation component that can be navigated between the Viewpager page
    4. Drawerlayout Add navigation Drawer that can create a drop-down
    5. Slidingpanelayout adds a view that creates a display profile and details for a screen that is adaptive to different sizes.
Equipment for barrier-free use

This part is designed for special people, such as deaf and dumb people.
1. Explorebytouchhelper
2. Accessibilityeventcompat
3. Accessibilitynodeinfocompat
4. Accessibilitynodeprovidercompat
5. Accessibilitydelegatecompat

Content processing
    1. Loader this loader class, this class primarily adds support for asynchronous loading data, while the V4 package also adds a specific implementation class for this class, including Cursorloader and Asynctaskloader
    2. Fileprovider This class adds support for sharing files between different apps
      There are a lot of useful classes in the V4 package, here are just a few of the more commonly used in daily development, a detailed description of the API class, please see:
      Https://developer.android.com/reference/android/support/v4/app/package-summary.html
      It is also easy to use this library in app engineering, you can download the jar package from this library and add it to app project, or you can add the library dependency in your Gradle profile so that Gradle automatically downloads the library and configures it:
com.android.support:support-v4:23.3.0
Multidex Support Library

This is a support library for Dalvik virtual machines, and when an app uses more than 65,535 methods, it needs to use the Multidex configuration, which is supported by adding this configuration. For more information on Multidex, please see:
Https://developer.android.com/studio/build/multidex.html
However, there are not so many ways to use the current major apps, so this library is less used.

V7 Support Libraries

This library is a system that runs on a version of Android 2.1 (API 7), which contains a series of sub-libraries that can exist and be applied to the app independently of each other.

V7 AppCompat Library

This is the app Compatibility library for the V7 library, which adds support for the action Bar UI design pattern, and adds UI design implementation support for material design. If your app wants to run in a version under Android 5.0 and wants the interface style of the material design, it must include this library. It is important to note that this library relies on the V4 library.
Here we list the key classes in several V7 libraries:
1. ActionBar This is the ActionBar implementation of the class, ActionBar is the application development of the more commonly used interface elements, it looks like this: The 2nd part of the

diagram is the ActionBar used to click the drop-down selection to perform the action. For more information on Actionbar see:
https://developer.android.com/design/patterns/actionbar.html
2. Appcompatactivity This is to implement a actionbar activity on a low version (API 7+), which means that if your app wants to be in the API Implementing Actionbar in more than 7 of Android versions you must integrate your activity class from the Appcompatactivity class, not the activity class.
3. Appcompatdialog provides dialog implementations based on the AppCompat theme
4. Shareactionprovider Add the Action Bar support for sharing information behavior, share the action bar like this:

Users can choose the form of shared data, and the code is simple, as long as the app is added to your menu's XML file: Actionproviderclass on the line:

<item android:id="@+id/action_share"      android:title="@string/share"      app:showAsAction="ifRoom"      app:actionProviderClass="android.support.v7.widget.ShareActionProvider"/>

It is also easy to use the V7 AppCompat support package in Gradle:

com.android.support:appcompat-v7:23.3.0
V7 CardView Library

This library mainly adds support for CardView, a widget that inherits from Framelayout, and is used primarily to implement a card-style UI effect with rounded and shaded effects in a material design style, such as:

For more information on CardView, please see:
Https://developer.android.com/training/material/lists-cards.html#CardView
To add the library in Gradle:

com.android.support:cardview-v7:23.3.0
V7 GridLayout Library

The library adds support for the grid layout, which is a grid layout that shows multiple patterns of similar information on one screen, and the grid layout is roughly as follows:

In addition, our home Desktop Program Launcher Layout is also a grid layout, used to display all the app's icon and name.
To add the library in Gradle:

com.android.support:gridlayout-v7:23.3.0
V7 Mediarouter Library

This library is a multimedia routing library, mainly provides Mediarouter, Mediarouteprovider and other classes, as well as the support of Google Cast, Google Cast is a new link device released by Google on July 25, 2013, The main operation of the simplified version of the Chrome OS, can be plugged into the TV's HDMI interface. For more information about Google Cast, please see the Google Cast website:
https://developers.google.com/cast/
The classes in this library primarily provide the option of routing local media streams to an external screen, audio player, and other target devices, which provide a media routing provider for publishing specific apps to find and select the right target device. For more detailed information about this library, please see the API manual:
Https://developer.android.com/reference/android/support/v7/media/package-summary.html
To add the library in Gradle:

com.android.support:mediarouter-v7:23.3.0
V7 Palette Library

The library mainly provides the function of the palette, which can be used to extract a color from a picture. For example, a music app may draw the theme color of a picture from the cover picture of the currently playing music, and then use this color to decorate the theme color of the current interface, which makes the interface softer and gives the user more sense of generation. One of the main classes in this library is the Palette class, the API for this class:
Https://developer.android.com/reference/android/support/v7/graphics/Palette.html
Use this library in Gradle:

com.android.support:palette-v7:23.3.0
V7 Recyclerview Library

The library is mainly to provide recyclerview this control, used in a limited window to display data items in an efficient and flexible way, about the use of recyclerview you can refer to this blog:
http://blog.csdn.net/lmj623565791/article/details/45059587
Use this library in Gradle:

com.android.support:recyclerview-v7:23.3.0
V7 Preference Support Library

This library is mainly the addition of preference support, including checkboxpreference and Listpreference classes.
Use this library in Gradle:

com.android.support:preference-v7:23.3.0
V8 Support Library

This is the V8 version of the support library, mainly run in Android 2.2 (API 8) above the version.

V8 Renderscript Library

This sub-Library provides renderscript support, Renderscript is a class C scripting language on the Android platform, which mainly implements the rendering function of graphics. For Renderscript Please see Google's instructions:
Https://developer.android.com/guide/topics/renderscript/compute.html
You can also view this blog:
Http://www.cnblogs.com/TerryBlog/archive/2012/03/02/2377251.html
Use this library in Gradle:

defaultConfig {    18    true}
V13 Support Library

This is the V13 version of the support library, the library is running the target is android3.2 (API 13) above the version, mainly to add the Fragment user interface mode support. For more information, see the Android Documentation:
Https://developer.android.com/reference/android/support/v13/app/package-summary.html
Use this library in Gradle:

com.android.support:support-v13:23.3.0
V14 Preference Support Library

Added support for richer preference, API documentation:
Https://developer.android.com/reference/android/support/v14/preference/package-summary.html
Use this library in Gradle:

com.android.support:preference-leanback-v17:23.3.0
V17 Leanback Library

The API classes added on TV big screen devices contain a lot of controls that are used on TV.
Use this library in Gadle:

com.android.support:leanback-v17:23.3.0
Annotations Support Library

Add Java annotation Support for more efficient implementation of software design. For Java annotations, see this blog:
Http://www.cnblogs.com/peida/archive/2013/04/24/3036689.html
The Android annotation support library is available with a look at the documentation for the Android tool group, simple and straightforward:
Http://tools.android.com/tech-docs/support-annotations
Use this library in Gradle:

com.android.support:support-annotations:23.3.0
Design Support Library

This library mainly adds support for material design, including many components and patterns for material design. About the use of this library can look at this foreigner wrote the blog, written very clear:
https://www.sitepoint.com/material-design-android-design-support-library/
Of course, if you are weak on the e-table, you can also look at the blog written by people:
http://blog.csdn.net/eclipsexys/article/details/46349721
Personal suggestions first look at the foreigner's article, and then in the Chinese article, combined to see the best.

Custom Tabs Support Library

This library makes it easy for app developers to add and manage custom tabs in the app, and for a description of custom tabs, see the Chrome website:
Https://developer.chrome.com/multidevice/android/customtabs

Support for library settings in development

This direct reference to Google's documentation, there is a picture of the truth, it is clear:
Https://developer.android.com/topic/libraries/support-library/setup.html

Support version Iteration history for libraries

Support libraries are growing along with Android and are constantly evolving, if you are interested in the version iteration history of the support library, you can view:
Https://developer.android.com/topic/libraries/support-library/revisions.html

Android Support Library Introduction

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.