Select Page

At Google I/O this year Google showed developers a preview release of Android L. That same day they put out a preview SDK so that developers could begin experimenting with the new API additions. This tutorial series will cover many of the new APIs unveiled in L in an easy to follow project format. The series will cover the following topics:

  • Current State of L (August 2014)
  • Stylesheet Changes
  • RecyclerView
  • CardView
  • Ripple Drawables
  • Palette
  • Activity Transitions
  • Elevation

The Project

In this project based tutorial we will construct a very simple application. The application will display a list of countries. Clicking on the images will take the user to a detail page. We will use various new Android L APIs to enrich the experience. For the sake of simplicity there will be no network component in this demo.

Setting Up L

For this tutorial we will be using the latest Android Studio release (8.2 on Beta Channel or 8.4 on Canary Channel). You will need to use the SDK manager to download the latest Android L APIs. Also make sure to update to the latest version of the Android SDK Tools, Platform-tool and Build-tools. For reference a screenshot of the SDK manager showing the latest versions as of August 2014 is included below.

Current State of L and a few Gotchas

Android L is still in an early state. Some APIs will undoubtedly change in the near future. Some of the APIs are not very well documented. I will link to any available documentation at the beginning of each section but it may not always be complete or it may be out of date.

We will be building an application targeting L only for the sake for the tutorial. Currently implementing the support library and compiling to an older build target requires some adjustments to your Gradle build. The L simulator works well (HAXM simulator recommended) but if you wish to deploy to a device for testing you will need to install the Nexus 5 or Nexus 7 images that Google provides.

You can find the images and the complete guide to setting up the preview SDK here!

Creating the L Project

If you have created projects in Android Studio before then feel free to skip this section.

  1. Open Android Studio and go to File > New Project. In the New Project window enter a title for the demo application. For this demo I have used WelcomeToL as the application name. Hit Next.
  2. Select the AI 20+: Android L (Preview) SDK for the Minimum SDK. Make sure only Phone and Tablet is checked. If you do not see the Android L SDK in the drop down list then you need to install it via the SDK Manager or point the SDK Manager to a different Android SDK location that has Android L. Hit Next.
  3. Select Blank Activity. For simplicity we will use only Activities in this demo. Hit Next.
  4. Give the initial Blank Activity a name. Because the first screen will display a list of names I have called this CountryActivity. Hit Finish.

New In L

Now that we have a new project lets take a look at some of the changes in the latest versions of L and Android Studio. First, if you are running Android Studio 8.4 (currently only in the Canary Channel) you have access to the new Android Project View. To change to the new view simply select Project in Project Navigator window. In the drop down the last choice will be Android. Select it and the new project view will appear.

This new project view greatly decreases the amount of clutter you will see in your project. Resources of the same name and type who vary only in density or target version will now appear stacked instead of hidden within their corresponding folder.

One final thing to look at is the latest theme. Open the styles.xml located in the v21 folder or appended with (v21) in project view. We have the same AppTheme entry you would have in previous versions except now instead of Holo we have the Theme.Material.Light theme by default.

Wrap-up

In the next part of this series we will focus on what is new in the Material Theme setup and set an initial color scheme for the demo application. The ongoing source code for this project can be found on github. The tag for this portion of the series is v0.1.

Github Source

Part 2: Material Theme Colors