Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 982
Daniel Gomez Rico Avatar asked Nov 16 '18 19:11

Daniel Gomez Rico


People also ask

How do I refactor on AndroidX?

With Android Studio 3.2 and higher, you can migrate an existing project to AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar. The refactor command makes use of two flags. By default, both of them are set to true in your gradle.

Why we need to migrate to AndroidX?

So, if you want bug fixes or new features that would have previously gone into the Support Library, you need to migrate to AndroidX. Better package management. With AndroidX, you get standardized and independent versioning, as well as better standardized naming and more frequent releases.

What is AndroidX AppCompat?

Android AppCompat Library The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later.

Does Android use material design?

Android provides the following features to help you build material design apps: A material design app theme to style all your UI widgets. Widgets for complex views such as lists and cards.


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

like image 158
Cameron Ketcham Avatar answered Oct 15 '22 22:10

Cameron Ketcham