开发者

RadioButton as flat button?

Is there a way to style a RadioButton as a flat button? I have four options:

| btn1 | btn2 | btn3 | btn4 |

instead of having the little radio circle next to each, I'd like to show each as just a plain flat button. Is that possible without havin开发者_如何学Gog to draw them myself?

Thanks


Yes it is possible.

In xml set, android:button="@null"

And in case you want to do it dynamically, setButtonDrawable(new StateListDrawable());


Yes, you can change the drawable used for a radio button.

android:button (or setButtonDrawable) controls the image used for the circle. Set it to null if you want no image.

You could then set the background of the radio button with android:background or setBackgroundResource to a normal button-style background.


Please see my question here for related help. I have been trying to get the "radio circle" to disappear too (which i can get it to work in the xml as shown in my example on the linked page) but it doesn't work if i try to do it dynamically.

Hope this helps and any help on my issue would be appreciated. Thanks.


Try this segmented control button library on github: https://github.com/bookwormat/segcontrol

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜