【发布时间】:2018-05-29 14:57:21
【问题描述】:
我需要将按钮背景颜色更改为红色。
我试试这个button.SetBackgroundColor(Color.Red);,但按钮变大了,然后我试试这个button.BackgroundTintList = (ColorStateList.ValueOf(Color.Red));,效果很好。
但在那之后我需要像以前一样放置背景按钮,但我不能这样做。我有另一个具有相同背景的按钮,并尝试使用它从那里复制
Button anotherButton = _v.FindViewById<Button>(Resource.Id.bt_anotherButton);
button.Background = anotherButton.Background;
但不是把另一个按钮背景等于按钮背景,而是相反,两个按钮都变成了红色。
有人可以帮忙吗?
【问题讨论】:
-
可以保存以前的颜色。或者您可以使用 Selector drawable 来绘制多个状态。
-
我正在尝试保存以前的背景,但我做不到。我有这个
Drawable dr = button.Background;然后把博士作为免费但保持红色