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

让人想犯罪 __ 提交于 2019-12-10 18:17:49

问题


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:


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



来源:https://stackoverflow.com/questions/53344551/how-to-style-an-app-migrating-to-materialcomponents-androidx-and-appcompat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!