【问题标题】:How to set text color for MaterialButton from code?如何从代码中为 MaterialButton 设置文本颜色?
【发布时间】:2018-09-04 11:58:50
【问题描述】:

我正在使用具有轮廓样式的 MaterialButton,并且无法从代码中设置文本颜色。有 setTextColor 方法吗?我可以通过 android:textColor 从 XML 更改它,但不能从代码更改。

使用com.google.android.material:material:1.0.0-rc01

【问题讨论】:

  • 你可以使用 text.setTextColor(Color.RED);
  • @NagendraHariKarthick 解决方案将起作用,但如果您不必更改此颜色,请使用主题配置提供的颜色。

标签: android material-components material-components-android


【解决方案1】:

1.0.0-rc01版本存在bug,在release版本中修复。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-14
    • 1970-01-01
    • 1970-01-01
    • 2017-02-04
    • 2019-07-10
    相关资源
    最近更新 更多