How to style an app migrating to MaterialComponents, AndroidX and AppCompat

Viewed 2079

I want to migrate to:

  • androidx.appcompat:appcompat
  • com.google.android.material:material

And forget about support library dependencies, but I have some questions:

  1. Which style should I use for ProgressBar in order to maintain compatibility?

    • v21: Widget.ProgressBar.Horizontal
    • Support Library: Widget.AppCompat.ProgressBar
  2. When should I use compat styles vs materialcomponents styles? Like @style/TextAppearance.MaterialComponents.Body1 or TextAppearance.AppCompat.Title ?

Im still confused about MaterialComponents and AppCompat libraries differences.

1 Answers

MaterialComponents is built on top of AppCompat, so generally AppCompat styles will work. However, if a MaterialComponents version of a style exists, you should use that instead.

For ProgressBar specifically, as of now there is no MaterialComponents version so you should use an AppCompat style such as Widget.AppCompat.ProgressBar. There's more info from a similar question here: https://github.com/material-components/material-components-android/issues/218

Related