Skip to content

Most visited

Recently visited


Maintaining Compatibility

Some material design features like the material theme and custom activity transitions are only available on Android 5.0 (API level 21) and above. However, you can design your apps to make use of these features when running on devices that support material design and still be compatible with devices running previous releases of Android.

Define Alternative Styles

You can configure your app to use the material theme on devices that support it and revert to an older theme on devices running earlier versions of Android:

  1. Define a theme that inherits from an older theme (like Holo) in res/values/styles.xml.
  2. Define a theme with the same name that inherits from the material theme in res/values-v21/styles.xml.
  3. Set this theme as your app's theme in the manifest file.

Note: If your app uses the material theme but does not provide an alternative theme in this manner, your app will not run on versions of Android earlier than 5.0.

Provide Alternative Layouts

If the layouts that you design according to the material design guidelines do not use any of the new XML attributes introduced in Android 5.0 (API level 21), they will work on previous versions of Android. Otherwise, you can provide alternative layouts. You can also provide alternative layouts to customize how your app looks on earlier versions of Android.

Create your layout files for Android 5.0 (API level 21) inside res/layout-v21/ and your alternative layout files for earlier versions of Android inside res/layout/. For example, res/layout/my_activity.xml is an alternative layout for res/layout-v21/my_activity.xml.

To avoid duplication of code, define your styles inside res/values/, modify the styles in res/values-v21/ for the new APIs, and use style inheritance, defining base styles in res/values/ and inheriting from those in res/values-v21/.

Use the Support Library

The v7 Support Libraries r21 and above includes the following material design features:

Updated support library versions may provide additional support for material design features. See the Support Library revision history for more information.

System widgets

The Theme.AppCompat themes provide material design styles for these widgets:

Color Palette

To obtain material design styles and customize the color palette with the Android v7 Support Library, apply one of the Theme.AppCompat themes:

<!-- extend one of the Theme.AppCompat themes -->
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
    <!-- customize the color palette -->
    <item name="colorPrimary">@color/material_blue_500</item>
    <item name="colorPrimaryDark">@color/material_blue_700</item>
    <item name="colorAccent">@color/material_green_A200</item>

Lists and Cards

The RecyclerView and CardView widgets are available in earlier versions of Android through the Android v7 Support Library with these limitations:


To use these features in versions of Android earlier than 5.0 (API level 21), include the Android v7 Support Library in your project as a Gradle dependency:

dependencies {
    compile ''
    compile ''
    compile ''

Check the System Version

The following framework features are available only in Android 5.0 (API level 21) and above:

To preserve compatibility with earlier versions of Android, check the system version at runtime before you invoke the APIs for any of these features:

// Check if we're running on Android 5.0 or higher
    // Call some material design APIs here
} else {
    // Implement this feature without material design

Note: To specify which versions of Android your app supports, use the android:minSdkVersion and android:targetSdkVersion attributes in your manifest file. To use the material design features in Android 5.0, set the android:targetSdkVersion attribute to 21. For more information, see the <uses-sdk> API guide.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)