问题描述
我想创建一个自定义视图充气器,它将继承自 MaterialComponentsViewInflater
并覆盖 createButton
函数以返回一个新的 AppCompatButton
而不是一个新的 MaterialButton
(我需要这个的原因是我面临的 this 问题)。创建类很容易,但我找不到如何告诉样式资源使用新类,因为它是充气器。我想也许根本没有选择,但后来我看到了 this 评论。我又看了一遍,但找不到关于该主题的一页。任何人都知道如何实现这一目标?
解决方法
尝试使用 Bridge 主题:
Theme.MaterialComponents.Bridge
Theme.MaterialComponents.Light.Bridge
Theme.MaterialComponents.NoActionBar.Bridge
Theme.MaterialComponents.Light.NoActionBar.Bridge
Theme.MaterialComponents.Light.DarkActionBar.Bridge