
Note: You can also apply an android:theme per in your Manifest.

To start using one of these themes in your app, you’d add the following to your res/styles.xml file: įinally, you need to reference this in your Manifest. Note 2: Some secondary variants are not shown here, such as .* themes. Note 1: If you are migrating an existing theme and don’t wish to get all of the new attributes at once, use a Theme.MaterialComponents.*.Bridge variant. There exists DayNight variants of these for supporting automatic dark/light theming. The key differences in each variant are the light/dark color palettes and the inclusion/exclusion of an ActionBar in each themed Activity‘s Window.

Material Components themes (from left to right):, Choosing a Material Components theme 🤔Īs with the AppCompat themes, the Material Components themes include a few base variants for you to choose from: You can track new releases on the GitHub repository. Following this have been independent feature releases and, at the time of writing, the latest version is 1.2.0-alpha06. The initial 1.0.0 release was mostly just a port of the existing classes over to the new namespace. Material Components for Android is under active development. This is as simple as adding a single Gradle dependency to your app/module adle file: implementation ":material:$material_version " Given that the Theme.MaterialComponents themes extend the pre-existing Theme.AppCompat variants, they inherit all of their attributes (think colorAccent, colorControlNormal, etc.), which will not be covered.

This article will only cover the new global theme attributes and per-widget style attributes that are introduced. In either case, the core widgets you incorporate into your app now mostly fall under the package and bring with them a variety of new theme/style attributes. Alternatively, perhaps you’re in the fortunate situation of starting an app from scratch and get to use these new libraries right away. So, you’ve migrated your Android app to AndroidX and, in the process, have also switched to using Material Components for Android as opposed to the Design Support Library.
