【问题标题】:android studio - I want to change background color of circular buttonandroid studio - 我想改变圆形按钮的背景颜色
【发布时间】:2019-10-27 18:04:59
【问题描述】:

我正在制作一个圆形按钮,它可以改变颜色并保留它。

我正在尝试使用

button.etBackgroundColor(getColor(R.color.color));

但在这种情况下,新颜色不是圆形而是方形。

我读过

Change background color of circular button android

但是我看不懂,也没有具体的解释。

我该怎么办?

【问题讨论】:

  • setColorFilter() 用于改变颜色像素。如果您阅读此developer.android.com/reference/android/graphics/drawable/… 会更好。如果您对此感到困惑,那么最好为圆形类型的圆形颜色按钮创建一个新的资源 xml,然后在按钮背景中使用它。
  • 抱歉,这不是我的问题;(

标签: android button


【解决方案1】:

您可以通过设置背景色调颜色来更改按钮背景颜色,如下所示

button.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#00FFAA"))); // Just replace code with your color code 

它会为你工作。

【讨论】:

    猜你喜欢
    • 2014-11-05
    • 1970-01-01
    • 2021-07-05
    • 2015-09-09
    • 2015-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-25
    相关资源
    最近更新 更多