Material Design, Appcompat, and Backwards Compatibility

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



Leave a reply



Submit