关于 Support v4 v7 v13 以及 Appcompat v7

文章翻译自谷歌官方文档

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.

Android Support Library 包含了多个libraries,并且能被继承在你的应用程序程序中,每一个libraries支持一堆指定的 Android 版本和特性

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.

这篇文章展示来自the Support Libraries的这些重要的特性和版本支持已经帮助你决定你需要在你的应用程序中集成哪些包.通常情况下,我们推荐在你的应用程序中包含 V4 support 和 v7 appcompat 包,因为这两个包能提供一个大范围的 Android 版本支持以及推荐的 UI 模式

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.

如果你想要使用如下的 libraries,你必须把这些包下载到 Android SDK 安装位置,步骤请点 连接.你需要一些额外的步骤来在你应用程序中集成指定的 support 包,

v4 Support Library

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:

这个 Library 为 Android1.6以及以后设计的.它相对其他版本的 Library 来说包含了 最多的 APIs.

下面是 v4包中关键的 classes

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 a ViewGroup 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 of ViewPager. 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 for AccessibilityEvent. For more information about implementing accessibility, see Accessibility. AccessibilityNodeInfoCompat - Adds support for AccessibilityNodeInfo. AccessibilityNodeProviderCompat - Adds support for AccessibilityNodeProvider. AccessibilityDelegateCompat - Adds support for View.AccessibilityDelegate. Content Loader - Adds support for asynchronous loading of data. The library also provides concrete implementations of this class, including CursorLoader and AsyncTaskLoader. 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.

如何在应用程序中集成

This library is located in the /extras/android/support/v4/ directory after you download the Android Support Libraries. 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:

com.android.support:support-v4:21.0.+

This dependency notation specifies the latest release version with the 21.0 prefix.

这个依赖标记指定最后发布版本是以21.0为前缀的 这里的 21 是以 android5.0 为模板,做给 android1.6级以上版本使用的的意思 . 就是 21.0.+表示 这个 support v4的包 拥有的是 api21 的特性 21表示它是随着 android5.0(API 21)一起发布的.意思是使用Android5.0的 sdk 来做的兼容包

Multidex(超出dex包数) 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.

如果一个用程序涉及的方法超过65536个,那么就需要用这个包了

This library is located in the /extras/android/support/multidex/ directory after you download the Android Support Libraries. The library does not contain user interface resources. To include it in your application project, follow the instructions for Adding libraries without resources.

The Gradle build script dependency identifier for this library is as follows:

com.android.support:multidex:1.0.+

This dependency notation specifies the latest release version with the 1.0 prefix.

v7 Support Libraries

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.

为 Android2.1之后设计的. support v7 包含 support v4 以及 appcompat v7

v7 appcompat library

This library adds support for the Action Bar user interface design pattern. This library includes support for material designuser interface implementations.

appcompat 为2.1添加了 ActionBar UI 设计模式,以及 material design 的 UI 支持

Note(提示): This library depends on the v4 Support Library. If you are using Ant or Eclipse, make sure you include the v4 Support Library as part of this library's classpath.

Here are a few of the key classes included in the v7 appcompat library:

下面是 appcompatv7包中主要包含的特性

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. ActionBarActivity - Adds an application activity class that must be used as a base class for activities that uses the Support Library action bar implementation. ShareActionProvider - Adds support for a standardized sharing action (such as email or posting to social applications) that can be included in an action bar.(分享到.) This library is located in the /extras/android/support/v7/appcompat/ directory after you download the Android Support Libraries. 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:

com.android.support:appcompat-v7:21.0.+

This dependency notation specifies the latest release version with the 21.0 prefix.

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.

这个 Library 提供了 CardView 这个 widget 支持.让你可以把信息展现在卡片之中获取和其他应用程序一致的体验.这些卡片将使用material design 实现.(主要用在 TV 版本的应用中)

This library is located in the /extras/android/support/v7/cardview/ directory after you download the Android Support Libraries. 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:

com.android.support:cardview-v7:21.0.+

This dependency notation specifies the latest release version with the 21.0 prefix.

v7 gridlayout library

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.widgetpackage in the API reference.

This library is located in the /extras/android/support/v7/gridlayout/ directory after you download the Android Support Libraries. 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:

com.android.support:gridlayout-v7:21.0.+ This dependency notation specifies the latest release version with the 21.0 prefix.

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.mediapackage in the API reference.

The v7 mediarouter library is located in the /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. If you are developing in Eclipse/ADT, make sure to include both the android-support-v7-mediarouter.jar and android-support-v7-appcompat.jar files.

If you are using Android Studio, all you need to do is specify the Gradle build script dependency identifier com.android.support:support-v7-mediarouter:, where "" is the minimum revision at which the library is available. For example:

com.android.support:mediarouter-v7:21.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.

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.

调色板:用来解析 bitmap 的颜色组成,为material design 设计,获取全局化的颜色体验

This library is located in the /extras/android/support/v7/palette/ directory after you download the Android Support Libraries. The library does not contain user interface resources. To include it in your application project, follow the instructions for Adding libraries without resources.

The Gradle build script dependency identifier for this library is as follows:

com.android.support:palette-v7:21.0.+ This dependency notation specifies the latest release version with the 21.0 prefix.

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.

为 在小窗口中显示大数据设计的

This library is located in the /extras/android/support/v7/recyclerview/ directory after you download the Android Support Libraries. 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:

com.android.support:recyclerview-v7:21.0.+ This dependency notation specifies the latest release version with the 21.0 prefix.

v8 Support 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.

提供 RenderScript 支持.

Note: Use of RenderScript with the support library is supported with the Android Eclipse plugin and Ant build tools. It is not currently supported with Android Studio or Gradle-based builds.

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 the android.support.v13 package in the API reference.

为 Android 3.2以上设计的.

添加的支持 Fragment 的 UI 模式

This library is located in the /extras/android/support/v13/ directory after you download the Android Support Libraries. The library does not contain user interface resources. To include it in your application project, follow the instructions for Adding libraries without resources.

The Gradle build script dependency identifier for this library is as follows:

com.android.support:support-v13:18.0.+ This dependency notation specifies the latest release version with the 18.0 prefix.

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:

这个包是给TV 设备用的,主要提供了一些有用的 widgets

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 of DetailsFragment 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-provided SearchResultProvider. The SearchResultProvider returns the search results to theSearchFragment, which renders them into a RowsFragment. This library is located in the /extras/android/support/v17/leanback directory after you download the Android Support Libraries. 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:leanback-v17:21.0.+ This dependency notation specifies the latest release version with the 21.0 prefix.