开发者

Android Toggle Buttons Off Colors

I'm working with a ToggleButton in my Android app and it is functioning fine. The one issue I'm having is that I'd like to color of the button to be red in it's off state. Currently it's green in it's On state, so I'd like the off color to keep everything consistent and to give users a visual cue.

Un开发者_运维问答fortunately, I haven't been able to find any information on how to do this. I thought there would be a property or something I could set, but scanning through the button's documentation hasn't turned up anything. Is there a way to do this? If not, is there a better option someone could recommend? The ToggleButton has 95% of what I need, if I can get the Off color working, I'll have everything.

Thanks!


What your looking for is called a StateListDrawable. The developer doc is available here. There are plenty of examples on the internet on how to implement these. Google works great for this.

The downside of this, is it IMHO is quite a bit of work just to change the look of your widget. Whether or not the "return on investment" is worth it is totally up to you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜