The Android Support Library offers a number of features that are not built into the framework. These libraries offer backward-compatible versions of new features, provide useful UI elements that are not included in the framework, and provide a range of utilities that apps can draw on.
In many cases, a feature may be valuable to many app developers, but not appropriate to include in the Android framework itself. For example, an app might only need a feature for specialized use cases, such as to smooth the transition between different versions of the Android system.
To address these situations, the Android SDK includes several libraries collectively called the Android Support Library. App developers can include any of these libraries if they want to incorporate the library functionality into their apps.
Support libraries provide a range of different features:
- Backward-compatible versions of framework components.
- UI elements to implement the recommended Android layout patterns.
- Support for different form factors.
- Miscellaneous utility functions.
Support libraries allow apps running on older versions of the Android platform to support features made available on newer versions of the platform. For example, an app running on a version of Android lower than 5.0 (API level 21) that relies on framework classes cannot display material-design elements, as that version of the Android framework doesn't support material design. However, if the app incorporates the Support Library's appcompat library, the app has access to many of the features available in API level 21, including support for material design. As a result, your app can deliver a more consistent experience across a broader range of platform versions.
In some cases, the support library version of a class depends as much as
possible on the functionality that the framework provides. In these cases,
if an app calls one of the support class's methods, the support library's
behavior depends on what version of Android the app is running on. If the
framework provides the necessary functionality, the support library calls on
the framework to perform the task. If the app is running on an earlier
version of Android, and the framework doesn't expose the needed
functionality, the support library may try to provide the functionality
itself, or may act as a no-op. In either case, the app generally doesn't
need to check what version of Android it's running on; instead, the app
can rely on the support library to do those checks and choose appropriate
behavior. Generally, classes whose names end in
behave this way.
In other cases, the support library class provides a complete, standalone version of a framework class that does not rely on the availability of any framework APIs. These methods provide consistent behavior across all supported platforms.
In either case, the app does not need to check the system version at run time. The app can rely on the support library class to do the appropriate system checks, and modify its behavior as necessary.
Support for General Layout Patterns
Support libraries provide user interface elements not offered by
the Android framework. For example, the Android Support Library offers additional
layout classes, like
classes follow recommended Android design practices; for example, the Design
Library follows the principles of material design in a way that works across
many versions of Android.
By using these support library classes, you can avoid having to reinvent the
wheel; if your app has a particular user interface requirement, you can draw
on existing code, which provides a user interface that users will already be
familiar with. These elements also help you build an app that looks and feels
like a part of the Android ecosystem. For example, many apps need to display
arbitrarily long lists of elements, and need to be able to quickly and
efficiently reuse those elements as the list changes; this might be a list of
emails, contacts, music albums, and so on. Those apps can use the support
RecyclerView widget to display the
list. This saves the app developer from having to develop the list from
scratch, and also ensures that the user will see a list that looks and
behaves like lists in other apps.
Support for Different Form Factors
The Android SDK provides libraries for a number of different form factors, such as TV and wearables. An app can depend on the appropriate support library to provide functionality across a wide range of platform versions, and can provide content on external screens, speakers, and other destination devices.
The Android Support Library provides backward-compatible utility functions. Apps can use these utility functions to provide an appropriate user experience across a wide range of Android system versions. For example, support library permission methods behave appropriately depending on what platform version your app is running on. If the platform supports the runtime permissions model, these methods request the appropriate permission from the user; on platform versions that do not support the runtime permissions model, the methods check whether the appropriate permission was granted at install time.