【问题标题】:Wrong color in toolbar items MaterialButton on Api 21Api 21 上的工具栏项目 MaterialButton 中的颜色错误
【发布时间】:2020-07-21 19:03:11
【问题描述】:

我在 AppCompatActivity 的工具栏上设置了一些 Material 按钮作为 ActionMenuItem。然而,颜色仅在 Api 21 (Android 5) 上是错误的。 其他按钮被禁用,但基本上它们应该是蓝色的,但在 Api 21 上是红色的。 我正在设置这样的颜色

 buttonAction.setBackgroundTintList(menuItem.getColor(context));
 buttonAction.setStrokeColor(menuItem.getColor(context));
 buttonAction.setTextColor(menuItem.getColor(context));

【问题讨论】:

    标签: java android api button colors


    【解决方案1】:

    我设法自己修复了它。问题是默认背景设置为 ?attr/colorPrimary。我为 API 21 制作了新的颜色 xml,并将其设置为 @color/colorPrimary。我不知道这是否是最好的解决方案。如果有人有更好的答案,请写出来。

    【讨论】:

      猜你喜欢
      • 2014-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-09
      • 1970-01-01
      • 1970-01-01
      • 2015-12-20
      • 1970-01-01
      相关资源
      最近更新 更多