【问题标题】:Material Components theme renders TextButton incorrectlyMaterial Components 主题渲染 TextButton 不正确
【发布时间】:2019-03-11 06:27:41
【问题描述】:

按照getting-started 的说明更新我们的Android 应用以继承Theme.MaterialComponents.Light 后,纯文本按钮无法正确呈现。

在注释中,文档状态:

Note: Using a Material Components theme enables a custom view inflater 
which replaces default components with their Material counterparts. 
Currently, this only replaces <Button> XML components with 
<MaterialButton>.

有没有办法禁用自定义视图充气或修复按钮问题?

【问题讨论】:

  • “不正确”是什么意思?
  • 如果你看上面的例子,这些按钮应该看起来像文本按钮

标签: java android material-design android-theme material-components


【解决方案1】:

自定义充气器仅替换没有限定符的名称,因此您可以在需要使用特定视图时使用完整的限定名称。在您的情况下,将 &lt;Button&gt; 替换为 xml 中的 &lt;android.widget.Button&gt;

【讨论】:

    【解决方案2】:

    您使用的是Dialog 还是AppCompatDialog?如果您使用AppCompatDialog,我认为默认情况下它应该具有正确的样式。否则,您应该确保对话框使用此样式:@style/ThemeOverlay.MaterialComponents.Dialog 或设置的样式 buttonBarButtonStyle@style/Widget.MaterialComponents.Button.TextButton.Dialog

    【讨论】:

      猜你喜欢
      • 2017-01-06
      • 1970-01-01
      • 2011-03-19
      • 1970-01-01
      • 2017-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多