问题描述
我正在从AppCompat迁移到MaterialComponents,并且我希望保留一些以AppCompat为主题的小部件(例如底部导航栏)。但是,当我想将MaterialComponents主题应用于Buttons和TextFields时,必须将我的应用程序主题设置为MaterialComponents...。因此,我所有的小部件都是以MaterialComponents为主题的。我如何只制作一些以MaterialComponents为主题的小部件?我一直在寻找关于StackOverflow的答案,但找不到任何东西。
解决方法
您可以使用 Bridge 主题,例如:
Theme.MaterialComponents.Bridge
Theme.MaterialComponents.Light.Bridge
Theme.MaterialComponents.NoActionBar.Bridge
Theme.MaterialComponents.Light.NoActionBar.Bridge
Theme.MaterialComponents.Light.DarkActionBar.Bridge
Bridge 主题继承自 AppCompat 主题,但也为您定义了新的 Material Components 主题属性。如果您使用桥梁主题,则无需更改应用主题即可开始使用 Material Design 组件。 (来自文档)