Material Design backward compatibility
Updating this answer as Lollipop OS is officially released with support libraries, which you can use inside your project to provide compatibility to older versions.
Support library: 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.
If you are using Android Studio then you just need to include below dependency identifier:
com.android.support:appcompat-v7:21.0.+
Maintaining backward compatibility with Material Design
You should be using the non-android namespaced properties with the support library:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
</style>
No v21 version required. This will give you consistent behavior back to API level 7
Android Material Design & Backwards compatibility
You should actually extend your activity to AppCompatActivity
which is latest and recommended by google. ActionBarActivity is deprecated.
And you should use toolbar
instead of actionbar , again a material design pattern. for how to use it you can find it here: toolbar tutorial
If you are using the latest android design support library , you may use AppBarLayout instead of default action bar. A great guide to use the new design support library can be found here
Android Design Support Library And Material Design Backwards Compatibility?
You can use the support libraries to backport some features introduced with the last api (for example 21) to old devices running a previous api level.
For example, API21 introduced a new widget, the Toolbar. This widget can be used only in device with API >=21.
With the appcompat
rel.21 (a v7 Support library) you can use the Toolbar (pay attention to the package) to implement your Toolbar in old devices running API>=7.
This can happen because the support libraries are included in your apk.
The Design Support Library is a new library which add new features.
It contains views as Snackbar, TextInputLayout, FloatingActionButton, but it doesn't contain the Card.
So use this dependency for the design support library:
compile 'com.android.support:design:22.2.0'
This dependency to use the AppCompat library
compile 'com.android.support:appcompat-v7:22.2.0'
This dependency for the official CardView
compile 'com.android.support:cardview-v7:22.2.0'
Check the official doc for more info.
Related Topics
How to Get Free and Total Size of Each Storagevolume
How to Do Page Flip/Turn/Curl Effect in Android
How How to Do Ussd Requests on Android
Android Studio Build Fails with "Task '' Not Found in Root Project 'Myproject'."
Android Gradle Build Error:(9, 0) Gradle Dsl Method Not Found: 'Compile()'
Programmatic Screencapture on Mobile Device
Android Studio How to Run Gradle Sync Manually
Start a Fragment via Intent Within a Fragment
Render Error in Android Studio 3.0 Layout Editor
How to Create Always-Top Fullscreen Overlay Activity in Android
How to Run Opencv Code Without Opencv Manager
Fire a Pinch In/Out Command to Android Phone Using Adb
Android Background Service Is Restarting When Application Is Killed
Could Not Access the Package Manager. Is the System Running While Installing Android Application
Get the Last Picture Taken by User
Why Does Gradle Build My Module in Release Mode When the App Is in Debug
Android 11 Action_Open_Document_Tree: Set Initial Uri to the Documents Folder