文章出處


title: Android Support Library
tags: Support Library,支持庫
grammar_cjkRuby: true
---
DATE: 2016-5-13.

Support Library簡介

Android Support Library(安卓支持庫)是一系列代碼庫的集合,提供對早期Android 1.6+(API 4+)系統的兼容,并包含一些額外功能的API。每一個庫針對不同的Android平臺范圍,并提供特定的功能集合。

Support Library特性

下面將介紹不同支持庫所提供的主要功能和支持的安卓版本。通常,support v4 和 appcompat v7 包是推薦被包含到項目中,它們提供了最大范圍的Android版本支持,包含了一些符合UI設計規范的API。

v4 Support Library

v4庫被設計用來兼容Android 1.6(API 4)及以上的版本。相比其支持它庫,它包含最多的API,包括程序兼容支持、可操作性、UI特性、數據綁定、網絡連接、編程輔助工具類。
下面是一些關鍵的類:

程序組件

  1. Fragment
    Static library support version of the framework's Fragment. Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework Fragment documentation for a class overview.
    The main differences when using this support version instead of the framework version are:
    • Your activity must extend FragmentActivity
    • You must call getSupportFragmentManager() to get the FragmentManager
  2. NotificationCompat
    Helper for accessing features in Notification introduced after API level 4 in a backwards compatible fashion.
  3. LocalBroadcastManager
    Allows applications to easily register for and receive intents within a single application without broadcasting them globally.

UI控件類

  1. ViewPager:左右滑動切換的ViewGroup。
    Adds a ViewGroup that manages the layout for the child views, which the user can swipe between.
  2. PagerTitleStrip:ViewPager小圓點。
    Adds a non-interactive title strip, that can be added as a child of ViewPager.
  3. PagerTabStrip :頁簽。
    Adds a navigation widget for switching between paged views, that can also be used with ViewPager.
  4. DrawerLayout :側邊欄,拉出來。
    Adds support for creating a Navigation Drawer that can be pulled in from the edge of a window.
  5. 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.

數據操作

  • 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.

在開發文檔API Reference中包android.support.v4下可以看到v4庫完整的類、接口等。
v4庫文件位于sdk目錄<sdk>/extras/android/support/v4/中,不包含UI資源(添加帶資源的安卓庫)。
使用v4庫對應的Gradle依賴指令:com.android.support:support-v4:18.0.+

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系列庫是針對API 7(Android 2.1)及以上系統的,v7系列包含多個獨立的庫,可根據它們的功能和項目需要分別引用。

v7 appcompat library兼容庫

This library adds support for the Action Bar user interface design pattern.
為早先系統提供新版UI設計理念提出的Action Bar的支持,它依賴v4庫。

下面列舉v7兼容庫的關鍵API:

  • 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.

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.widget package in the API reference.
可以在包android.support.v7.widget下查看所有提供的API,GridLayout 不是適配器視圖,不像GridView那樣提供一致性的視圖項目,可以靈活顯示不同的內容,如Android中計算器布局。GridLayout 的繼承層級較淺,性能比GridView好。

v7 mediarouter library

This library provides MediaRouter, MediaRouteProvider, and related media classes that support Google Cast.

v8 Support Library

引入:Render Script,在開發文檔中“Develop > API Guides > Computation”中有詳細介紹。
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.

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

Support classes to access some of the android.app package features introduced after API level 13 in a backwards compatible fashion.

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開發文檔

  • Develop > Tools > Support Library.

文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()