如何设置要迁移到MaterialComponents,AndroidX和AppCompat的应用程序的样式 [英] How to style an app migrating to MaterialComponents, AndroidX and AppCompat

查看:116
本文介绍了如何设置要迁移到MaterialComponents,AndroidX和AppCompat的应用程序的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想迁移到:

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

忘了支持库的依赖性,但是我有一些疑问:

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

  1. ProgressBar应该使用哪种样式以保持兼容性?

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

  • v21:Widget.ProgressBar.Horizontal
  • 支持库:Widget.AppCompat.ProgressBar
  • v21: Widget.ProgressBar.Horizontal
  • Support Library: Widget.AppCompat.ProgressBar

何时应使用compat样式与materialcomponents样式? 像@style/TextAppearance.MaterialComponents.Body1TextAppearance.AppCompat.Title吗?

When should I use compat styles vs materialcomponents styles? Like @style/TextAppearance.MaterialComponents.Body1 or TextAppearance.AppCompat.Title ?

我仍然对MaterialComponentsAppCompat库的区别感到困惑.

Im still confused about MaterialComponents and AppCompat libraries differences.

推荐答案

MaterialComponents建立在AppCompat的顶部,因此通常AppCompat样式都可以使用.但是,如果存在样式的MaterialComponents版本,则应改用该版本.

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.

特别是对于ProgressBar,到目前为止,还没有MaterialComponents版本,因此您应该使用AppCompat样式,例如Widget.AppCompat.ProgressBar.这里有类似问题的更多信息: https://github.com/material-components/material-components-android/issues/218

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

这篇关于如何设置要迁移到MaterialComponents,AndroidX和AppCompat的应用程序的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆