Learn how to use the new Android Themes in your App

Newer versions of Android have additional themes available to applications, and you might want to use these while running on those platforms while still being compatible with older versions.  – Android Documentation

Since your app targets devices which run on API level 17 and above you don’t need to provide backward compatibility. You can make use of the new Themes.

Let’s see how.

You are going to change the app so that it uses Theme.Holo.Light by default and switches to Theme.Material.Light if app is running on API level 21.

  1. Open MainActivity class. Change ActionBarActivity to Activity.
  2. You will notice there are two style.xml files. One which supports v21 and other for lower versions (default).

Change default style.xml to use the following parent theme – android.Theme.Holo.Light

Change v21 style.xml to use the following parent theme – android.Theme.Material.Light

Follow the video to understand better. Source Code is available here