The Material Components for Android
The example shown in this chapter uses a theme based on Theme.AppCompat
. All of the sample apps in the Sampler
and SamplerJ
projects use themes based on Theme.AppCompat
.
However, HelloWorld
and HelloWorldJ
do not. As we saw earlier in the book, those samples use a theme based on something called Theme.MaterialComponents
.
This comes from a library known as the Material Components for Android. Principally, this library offers a series of widgets that implement some of the UI components seen in Material Design, from bottom navigation bars to snackbars to “FABs” (floating action buttons). This library also uses a different theme system that uses a different set of color names.
In the author’s opinion, the Material Components for Android represents a fine library for experienced Android developers, but it is a poor choice for newcomers. That is why the book continues to use Theme.AppCompat
— the results that you get are more in line with what documentation and other existing written material covers.
Note, though, that the Android Studio new-project wizard will create a project that uses the Material Components for Android. To switch to AppCompat:
- Replace the theme and its colors with ones from an AppCompat-based project, such as one from this book
- Remove
com.google.android.material:material
from your module’s list of dependencies (as you will no longer be needing it)
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.