From AppCompat to Material Components + Applying Dark theme to Android (Part 3/4)

Shubham Gupta
2 min readApr 11, 2020

Using the Shape design system in your Android apps.

Hey readers,

This is the 3rd part of how to move from AppCompat to Material Theming Components. Check out the 1st part and the 2nd part:

Till now we have implemented the Color and Typography into our apps and taken the second step to implement the new Material Design library. The next step is to implement a consistent Shape system in our apps.

Shape

With Material Theming we can implement shapes easily. Previously we used to do various tricks to provide a rounded or a cut corner like using shape drawable. This comes inbuilt now.

Shapes are categorized into 3 types. The Material Design Components (aka MDC) falls into one of these categories as shown below:

3 categories: Small, Medium, and Large (credits: Google)

Thus, if you change the shape appearance of the Medium components, components such as Card, Dialog, and Menu will change their shape as well. This provides consistency across our app.

Steps to use the Shape system:

  1. Create a new shape.xml file under res folder i.e. res/values/shape.xml — This file will contain all the shape appearances for all the categories.
  2. Override the default shape appearances —Here’s an example:

In the above example, every button will have our own custom styles. It will look something like this:

Custom button on a light theme (using colorPrimary as the background)
Custom button on a default dark theme(without adding dark styles)

--

--

Shubham Gupta

Programming Enthusiast, Google Certified Android Developer, Sarcasm and Humour lover, Being a better me.