如何为迁移到 MaterialComponents、AndroidX 和 AppCompat 的应用设置样式
How to style an app migrating to MaterialComponents, AndroidX and AppCompat
我想迁移到:
androidx.appcompat:appcompat
com.google.android.material:material
忘记支持库依赖项,但我有一些问题:
我应该为 ProgressBar
使用哪种样式以保持兼容性?
- v21:
Widget.ProgressBar.Horizontal
- 支持库:
Widget.AppCompat.ProgressBar
什么时候应该使用 compat 样式与 materialcomponents 样式?
喜欢 @style/TextAppearance.MaterialComponents.Body1
或 TextAppearance.AppCompat.Title
?
我仍然对 MaterialComponents
和 AppCompat
库的差异感到困惑。
MaterialComponents 构建在 AppCompat 之上,因此通常 AppCompat 样式都可以使用。但是,如果存在样式的 MaterialComponents 版本,您应该改用它。
具体到 ProgressBar,截至目前还没有 MaterialComponents 版本,因此您应该使用 AppCompat 样式,例如 Widget.AppCompat.ProgressBar
。这里有来自类似问题的更多信息:https://github.com/material-components/material-components-android/issues/218
我想迁移到:
androidx.appcompat:appcompat
com.google.android.material:material
忘记支持库依赖项,但我有一些问题:
我应该为
ProgressBar
使用哪种样式以保持兼容性?- v21:
Widget.ProgressBar.Horizontal
- 支持库:
Widget.AppCompat.ProgressBar
- v21:
什么时候应该使用 compat 样式与 materialcomponents 样式? 喜欢
@style/TextAppearance.MaterialComponents.Body1
或TextAppearance.AppCompat.Title
?
我仍然对 MaterialComponents
和 AppCompat
库的差异感到困惑。
MaterialComponents 构建在 AppCompat 之上,因此通常 AppCompat 样式都可以使用。但是,如果存在样式的 MaterialComponents 版本,您应该改用它。
具体到 ProgressBar,截至目前还没有 MaterialComponents 版本,因此您应该使用 AppCompat 样式,例如 Widget.AppCompat.ProgressBar
。这里有来自类似问题的更多信息:https://github.com/material-components/material-components-android/issues/218