Support Library官方教程(2)各支援包的特性详介(含表)*
1.各支援包简介表
包名 |
作用 | 位置 | 是否有资源 |
v4 |
提供了最多的api |
|
|
Multidex |
把DEX文件生成apk |
<sdk>/extras/android/support/multidex/ |
n |
v7 appcompat |
在v4上增加action bar,依赖 v4包 |
<sdk>/extras/android/support/v7/appcompat/ |
y |
v7 cardview |
CardView包 |
<sdk>/extras/android/support/v7/cardview/ |
y |
v7 gridlayout |
提供 GridLayout |
|
y |
v7 mediarouter |
提供对多媒体的控制 |
<sdk>/extras/android/support/v7/ |
y |
v7 palette |
提供调色板支持 |
<sdk>/extras/android/support/v7/palette/ |
n |
v7 recyclerview |
提供RecyclerView |
<sdk>/extras/android/support/v7/recyclerview/ |
y |
v7 Preference |
提供用户偏好设置类 |
<sdk>/extras/android/support/v7/ |
y |
v8 renderscript |
提供 renderscript |
build-tools/$VERSION/renderscript/ |
n |
v13 |
Fragment用户接口 |
<sdk>/extras/android/support/v13/ |
n |
v14 Preference |
增加用户偏好设置相关的类 |
<sdk>/extras/android/support/v14/ |
n |
v17 Preference tv |
主要提供 tv设备上的偏好设置类 |
<sdk>/extras/android/support/v17/ |
n |
v17 Leanback |
tv设备上的用户界面接口类 |
<sdk>/extras/android/support/v17/ |
y |
Annotations |
数据源 |
<sdk>/extras/android/support/annotations |
y |
Design |
设计包 |
<sdk>/extras/android/support/design |
y |
Custom Tabs |
自定义tab包 |
<sdk>/extras/android/support/customtabs |
y |
Percent Support |
|
y |
|
App Recommendation tv |
tv设置提供应用推荐包 |
|
y |
2.Support Library Features
The Android Support Library package contains several libraries that can be included in your application. Each of these libraries supports a specific range of Android platform versions and set of features.
每个support libary拥有不同特性。
This guide explains the important features and version support provided by the Support Libraries to help you decide which of them you should include in your application. In general, we recommend including the v4 support and v7 appcompat libraries, because they support a wide range of Android versions and provide APIs for recommended user interface patterns.
目前(2015)推荐使用v4 support and v7 appcompat 这两个系列支援包,它们的适用的api范围最广,提供了大量的用户界面接口。
In order to use any of the following libraries, you must download the library files to your Android SDK installation. Follow the directions for downloading the Support Libraries in Support Library Setup to complete this step. You must take additional steps to include a specific Support Library in your application. See the end of each library section below for important information on how to include the library in your application.
在项目中使用support libary要额外的步骤。
3.v4 Support Library (V4系列支援包)
This library is designed to be used with Android 1.6 (API level 4) and higher. It includes the largest set of APIs compared to the other libraries, including support for application components, user interface features, accessibility, data handling, network connectivity, and programming utilities. Here are a few of the key classes included in the v4 library:
v4 相比其它支援包,提供了最多的api。下面是v4中包含的重要api:
- App Components
Fragment
- Adds support for encapsulation of user interface and functionality with Fragments, enabling applications to provide layouts that adjust between small and large-screen devices.NotificationCompat
- Adds support for rich notification features.LocalBroadcastManager
- Allows applications to easily register for and receive intents within a single application without broadcasting them globally.
- User Interface
ViewPager
- Adds aViewGroup
that manages the layout for the child views, which the user can swipe between.PagerTitleStrip
- Adds a non-interactive title strip, that can be added as a child ofViewPager
.PagerTabStrip
- Adds a navigation widget for switching between paged views, that can also be used withViewPager
.DrawerLayout
- Adds support for creating a Navigation Drawer that can be pulled in from the edge of a window.SlidingPaneLayout
- Adds widget for creating linked summary and detail views that appropriately adapt to various screen sizes.
- Accessibility
ExploreByTouchHelper
- Adds a helper class for implementing accessibility support for custom views.AccessibilityEventCompat
- Adds support forAccessibilityEvent
. For more information about implementing accessibility, see Accessibility.AccessibilityNodeInfoCompat
- Adds support forAccessibilityNodeInfo
.AccessibilityNodeProviderCompat
- Adds support forAccessibilityNodeProvider
.AccessibilityDelegateCompat
- Adds support forView.AccessibilityDelegate
.
- Content
Loader
- Adds support for asynchronous loading of data. The library also provides concrete implementations of this class, includingCursorLoader
andAsyncTaskLoader
.FileProvider
- Adds support for sharing of private files between applications.
There are many other APIs included in this library. For complete, detailed information about the v4 Support Library APIs, see the android.support.v4
package in the API reference.
可通过下面链接 查看 android.support.v4 的详细api
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/v4/
directory. The library does not contain user interface resources. To include it in your application project, follow the instructions for Adding libraries without resources.
Caution: Using dynamic dependencies, especially for higher version numbers, can cause unexpected version updates and regression incompatibilities.
The Gradle build script dependency identifier for this library is as follows:
以 Gradle脚本生成工程的项目 用下面方法添加 该lib
com.android.support:support-v4:23.1.0
4.Multidex Support Library
This library provides support for building apps with multiple Dalvik Executable (DEX) files. Apps that reference more than 65536 methods are required to use multidex configurations. For more information about using multidex, see Building Apps with Over 65K Methods.
这个库用来把DEX文件生成apk。 见 Building Apps with Over 65K Methods。
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/multidex/
directory. The library does not contain user interface resources. To include it in your application project, follow the instructions for Adding libraries without resources.
下载后目录在 <sdk>/extras/android/support/multidex/ 下,该库没有用户界面资源。在gradle脚本中添加方法如下:
The Gradle build script dependency identifier for this library is as follows:
com.android.support:multidex:1.0.0
5.v7 Support Libraries(v7系列支援包)
There are several libraries designed to be used with Android 2.1 (API level 7) and higher. These libraries provide specific feature sets and can be included in your application independently from each other.
v7 支援包中包含了一系列包,按需求引用。下面介绍
5.1 v7 appcompat library
This library adds support for the Action Bar user interface design pattern. This library includes support for material design user interface implementations.
Note: This library depends on the v4 Support Library.
v7 compat包在v4基础上增加 action bar ,依赖 v4包,它包含的主要api如下:
Here are a few of the key classes included in the v7 appcompat library:
ActionBar
- Provides an implementation of the action bar user interface pattern. For more information on using the Action Bar, see the Action Bar developer guide.AppCompatActivity
- Adds an application activity class that can be used as a base class for activities that use the Support Library action bar implementation.AppCompatDialog
- Adds a dialog class that can be used as a base class for AppCompat themed dialogs.ShareActionProvider
- Adds support for a standardized sharing action (such as email or posting to social applications) that can be included in an action bar.
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/v7/appcompat/
directory. The library contains user interface resources. To include it in your application project, follow the instructions for Adding libraries with resources.
v7 compat 包在<sdk>/extras/android/support/v7/appcompat/ 下,它包含用户界面资源。在gradle中添加的方法如下:
The Gradle build script dependency identifier for this library is as follows:
com.android.support:appcompat-v7:23.1.0
5.2 v7 cardview library
This library adds support for the CardView
widget, which lets you show information inside cards that have a consistent look on any app. These cards are useful for material design implementations, and are used extensively in layouts for TV apps.
v7 CardView包 包含控件 CardView。
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/v7/cardview/
directory. The library contains user interface resources. To include it in your application project, follow the instructions for Adding libraries with resources.
The Gradle build script dependency identifier for this library is as follows:
位置在 <sdk>/extras/android/support/v7/cardview/ 使用方法如下
com.android.support:cardview-v7:23.1.0
5.3 v7 gridlayout library
After you download the Android Support Libraries, this library adds support for the GridLayout
class, which allows you to arrange user interface elements using a grid of rectangular cells. For detailed information about the v7 gridlayout library APIs, see the android.support.v7.widget
package in the API reference.
v7 GridLayout 包提供 GridLayout
This library is located in the <sdk>/extras/android/support/v7/gridlayout/
directory . The library contains user interface resources. To include it in your application project, follow the instructions for Adding libraries with resources.
位置在 <sdk>/extras/android/support/v7/gridlayout/
,引用方法如下
The Gradle build script dependency identifier for this library is as follows:
com.android.support:gridlayout-v7:23.1.0
5.4 v7 mediarouter library
This library provides MediaRouter
, MediaRouteProvider
, and related media classes that support Google Cast.
In general, the APIs in the v7 mediarouter library provide a means of controlling the routing of media channels and streams from the current device to external screens, speakers, and other destination devices. The library includes APIs for publishing app-specific media route providers, for discovering and selecting destination devices, for checking media status, and more. For detailed information about the v7 mediarouter library APIs, see the android.support.v7.media
package in the API reference.
v7 mediarouter 提供对多媒体的控制
The v7 mediarouter library is located in the <sdk>/extras/android/support/v7/ mediarouter/
directory after you download the Android Support Library. It's provided as a library project with a dependency on the v7 appcompat library, so you'll need to include both libraries in your build path when setting up your project. For more information on how to set up your project, follow the instructions in Adding libraries with resources.
The Gradle builder script dependency identifier is as follows: com.android.support:support-v7-mediarouter:<revision>
, where "<revision>" is the minimum revision at which the library is available. For example:
位置在<sdk>/extras/android/support/v7/ 引用方法如下
com.android.support:mediarouter-v7:23.1.0
The v7 mediarouter library APIs introduced in Support Library r18 are subject to change in later revisions of the Support Library. At this time, we recommend using the library only in connection with Google Cast.
5.5 v7 palette library
The v7 palette support library includes the Palette
class, which lets you extract prominent colors from an image. For example, a music app could use a Palette
object to extract the major colors from an album cover, and use those colors to build a color-coordinated song title card.
v7 palette 包提供调色板支持
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/v7/palette/
directory. The library does not contain user interface resources. To include it in your application project, follow the instructions for Adding libraries without resources.
位置在<sdk>/extras/android/support/v7/palette/ 引用方法如下
The Gradle build script dependency identifier for this library is as follows:
com.android.support:palette-v7:23.1.0
5.6 v7 recyclerview library
The recyclerview library adds the RecyclerView
class. This class provides support for the RecyclerView widget, a view for efficiently displaying large data sets by providing a limited window of data items.
v7 recyclerview 包提供 RecyclerView
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/v7/recyclerview/
directory. The library contains user interface resources. To include it in your application project, follow the instructions for Adding libraries with resources.
位置在 <sdk>/extras/android/support/v7/recyclerview/ ,引用方法如下
The Gradle build script dependency identifier for this library is as follows:
com.android.support:recyclerview-v7:23.1.0
5.7 v7 Preference Support Library
The preference package provides APIs to support adding preference objects, such as CheckBoxPreference
and ListPreference
, for users to modify UI settings.
v7 preference包 提供 用户偏好设置类
The v7 Preference library adds support for interfaces, such as Preference.OnPreferenceChangeListener
and Preference.OnPreferenceClickListener
, and classes, such as CheckBoxPreference
and ListPreference
.
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/v7/ preference
directory. For more information on how to set up your project, follow the instructions in Adding libraries with resources.
位置在 <sdk>/extras/android/support/v7/ ,引用方法如下:
The Gradle build script dependency identifier for this library is as follows:
com.android.support:preference-v7:23.1.0
6. v8 Support Library(v8系列支援包)
This library is designed to be used with Android 2.2 (API level 8) and higher. This library provides specific feature sets and can be included in your application independently from other libraries.
6.1 v8 renderscript library
This library is designed to be used with Android (API level 8) and higher. It adds support for the RenderScript computation framework. These APIs are included in the android.support.v8.renderscript
package. You should be aware that the steps for including these APIs in your application is very different from other support library APIs. For more information about using these APIs in your application, see the RenderScript developer guide.
v8 renderscript包提供 renderscript ,相关资源 http://www.cnblogs.com/TerryBlog/archive/2012/03/02/2377251.html
Note: Use of RenderScript with the support library is supported with Android Studio and Gradle-based builds. The renderscript library is located in the build-tools/$VERSION/renderscript/
folder.
位置在build-tools/$VERSION/renderscript/,引用方法如下
The following example shows the Gradle build script properties for this library:
1 defaultConfig { 2 renderscriptTargetApi 18 3 renderscriptSupportModeEnabled true 4 }
6.v13 Support Library
This library is designed to be used for Android 3.2 (API level 13) and higher. It adds support for the Fragment user interface pattern with the (FragmentCompat
) class and additional fragment support classes. For more information about fragments, see the Fragments developer guide. For detailed information about the v13 Support Library APIs, see theandroid.support.v13
package in the API reference.
v13 包主要添加 Fragment用户接口的支持
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/v13/
directory. The library does not contain user interface resources. To include it in your application project, follow the instructions for Adding libraries without resources.
位置在 <sdk>/extras/android/support/v13/,引用方法如下:
The Gradle build script dependency identifier for this library is as follows:
com.android.support:support-v13:23.1.0
8.v14 Preference Support Library
The android.support.v14.preference
package provides APIs to add support for preference interfaces such as PreferenceFragment.OnPreferenceStartFragmentCallback
and PreferenceFragment.OnPreferenceStartScreenCallback
, along with classes, such as MultiSelectListPreference
and PreferenceFragment
. For detailed information about the v14 Preference Support Library APIs, see the preference package in the API reference.
v14 Preference包主要增加用户偏好设置相关的类
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/v14/
directory. The library does not contain user interface resources. To include it in your application project, follow the instructions for Adding libraries without resources.
位置在 <sdk>/extras/android/support/v14/ ,引用方法如下:
The Gradle build script dependency identifier for this library is as follows:
com.android.support:preference-v14:23.1.0
9.v17 Preference Support Library for TV
The android.support.v17.preference
package provides APIs for providing preference interfaces on TV devices, including support for the LeanbackListPreferenceDialogFragment.ViewHolder.OnItemClickListener
interface and classes, such as BaseLeanbackPreferenceFragment
and LeanbackPreferenceFragment
. For detailed information about the v17 Preference Support Library APIs, see the preference package in the API reference.
v17 Preference tv包主要提供 tv设备上的偏好设置类
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/v17/
directory. The library does not contain user interface resources. To include it in your application project, follow the instructions for Adding libraries without resources.
位置在 <sdk>/extras/android/support/v17/ ,引用方法如下:
The Gradle build script dependency identifier for this library is as follows:
com.android.support:preference-leanback-v17:23.1.0
10.v17 Leanback Library
The android.support.v17.leanback
package provides APIs to support building user interfaces on TV devices. It provides a number of important widgets for TV apps. Some of the notable classes include:
v17 Leanback包,主要提供tv设备上的用户界面接口类。主要的如下:
BrowseFragment
- A fragment for creating a primary layout for browsing categories and rows of media items.DetailsFragment
- A wrapper fragment for Leanback details screens.PlaybackOverlayFragment
- A subclass ofDetailsFragment
for displaying playback controls and related content.SearchFragment
- A fragment to handle searches. The fragment receives the user's search request and passes it to the application-providedSearchResultProvider
. TheSearchResultProvider
returns the search results to theSearchFragment
, which renders them into aRowsFragment
.
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/v17/leanback
directory. For more information on how to set up your project, follow the instructions in Adding libraries with resources.
位置在 <sdk>/extras/android/support/v17/leanback
,引用方法如下:
The Gradle build script dependency identifier for this library is as follows:
com.android.support:leanback-v17:23.1.0
11.Annotations Support Library
The Annotation package provides APIs to support adding annotation metadata to your apps.
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/annotations
directory. For more information on how to set up your project, follow the instructions in Adding libraries with resources.
annotation metadata包在 <sdk>/extras/android/support/annotations ,引用方法如下:
The Gradle build script dependency identifier for this library is as follows:
com.android.support:support-annotations:23.1.0
12.Design Support Library
The Design package provides APIs to support adding material design components and patterns to your apps.
The Design Support library adds support for various material design components and patterns for app developers to build upon, such as navigation drawers, floating action buttons (FAB), snackbars, and tabs.
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/design
directory. For more information on how to set up your project, follow the instructions in Adding libraries with resources.
design包位置在<sdk>/extras/android/support/design ,引用方法如下:
The Gradle build script dependency identifier for this library is as follows:
com.android.support:design:23.1.0
13.Custom Tabs Support Library
The Custom Tabs package provides APIs to support adding and managing custom tabs in your apps.
The Custom Tabs Support library adds support for various classes, such as Custom Tabs Service and Custom Tabs Callback.
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/customtabs
directory. For more information on how to set up your project, follow the instructions in Adding libraries with resources.
自定义tab包在<sdk>/extras/android/support/customtabs,引用方法如下:
The Gradle build script dependency identifier for this library is as follows:
com.android.support:customtabs:23.1.0
14.Percent Support Library
The Percent package provides APIs to support adding and managing percentage based dimensions in your app.
The Percent Support library adds support for the PercentLayoutHelper.PercentLayoutParams interface and various classes, such as PercentFrameLayout and PercentRelativeLayout.
百分比包 主要 提供PercentLayoutHelper.PercentLayoutParams系列类 ,位置在<sdk>/extras/android/support/percent
,引用方法如下:
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/percent
directory. For more information on how to set up your project, follow the instructions in Adding libraries with resources.
The Gradle build script dependency identifier for this library is as follows:
com.android.support:percent:23.1.0
15.App Recommendation Support Library for TV
The App Recommendation package provides APIs to support adding content recommendations in your app running on TV devices.
The App library adds support for annotations, such as ContentRecommendation.ContentMaturity and various classes, such as ContentRecommendation and RecommendationExtender.
为tv设置提供应用推荐包,主要包含ContentRecommendation.ContentMaturity,ContentRecommendation,RecommendationExtender等,位置在 <sdk>/extras/android/support/recommendation
,引用方法如下:
After you download the Android Support Libraries, this library is located in the <sdk>/extras/android/support/recommendation
directory. For more information on how to set up your project, follow the instructions in Adding libraries with resources.
The Gradle build script dependency identifier for this library is as follows:
com.android.support:recommendation:23.1.0