Material Design Specs Library

Along with the RecyclerViewCursorAdapter library that was released earlier this week, I have now released my second open source Android library. In collaboration with my good friend Maurício, we have built a library for including the Material Design Specs in your Android application. Currently, the library has the full color palette along with some helper methods, and some elevation resources to give the proper elevation to your components. The source code, as well as instructions for including the library can be found on GitHub, so go there to check it out and give us a star!


The convention for accessing the color resources is like so:


where colorName and colorLevel are replaced with the values you want. There are 19 color names:

  • red
  • pink
  • purple
  • deeppurple
  • indigo
  • blue
  • lightblue
  • cyan
  • teal
  • green
  • lightgreen
  • lime
  • yellow
  • amber
  • orange
  • deeporange
  • brown
  • grey
  • bluegrey

And there are 14 color levels:

  • 50
  • 100
  • 200
  • 300
  • 400
  • 500
  • 600
  • 700
  • 800
  • 900
  • A100
  • A200
  • A400
  • A700

The ones prefixed with an A represent accent shades. Please note that brown, grey, and bluegray do not have accent shades with them. With that, an example of a color may be R.color.mds_red_500 or R.color.mds_pink_A200.

Available helper methods include:

  • getColorsByName()
  • getAccentColorsByName()
  • getColorsByLevel()
  • getRandomColor()
  • getRandomNonAccentColor()
  • getRandomAccentColor()
  • getRandomColorByLevel()
  • getRandomColorByName()
  • getRandomColorNonRepeating()
  • getAllColors()

Each of these methods will throw an IllegalAccessException if any of the resources are unable to be accessed. For passing in the color name or color level, you can make use of the available static strings, such as:



Currently the only supported elevation values are those found from the elevation specs that follow convention:


where componentNAme can be replaced by “dialog” or “appbar”. With its current functionality, there is no need for programatic helper methods for using elevation values. This may change as more specs are included in the future.

We hope this gives you everything you need for moving forward and incorporating Material Design in your applications. If you feel like our library is missing anything, let us know in the comments or submit an issue on GitHub!

Adam McNeilly

Adam McNeilly
Adam is a Google Developer Expert for Android. He's been developing apps since 2015, and travels the world to present and learn from other Android engineers.

Interface Naming Conventions

Many engineers will tell you that one of the most complicated responsibilities of our job is naming things. Variables, classes, functions...… Continue reading