【问题标题】:Android. Set backgound color without change the shape安卓。在不改变形状的情况下设置背景颜色
【发布时间】:2014-01-28 01:51:19
【问题描述】:

我想在不改变形状的情况下设置按钮的背景颜色。

按钮如下:

 <Button 
   android:id="@+id/button_color"
   style="@style/button_menu"
   android:background="@drawable/gray_button"
   android:text="" />

其中 gray_button.xml 包含形状信息,在我的例子中是圆形。

如果我使用该功能

colorButton.setBackgroundColor(Color.rgb(r, g, b));

也会改变形状。

我该怎么办?

【问题讨论】:

  • 在按钮的背景 Drawable 上使用 setColorFilter
  • 谢谢。 setColorFilter 工作

标签: android xml button background shape


【解决方案1】:

您可以在 gray_button.xml 中添加背景颜色。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-13
    • 1970-01-01
    • 2015-12-13
    • 2014-09-22
    相关资源
    最近更新 更多