Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RadioButton as flat button?

Tags:

android

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 having to draw them myself?

Thanks

like image 808
user246114 Avatar asked Sep 01 '10 15:09

user246114


People also ask

How many methods of radio buttons are there?

RadioButton is a two states button which is either checked or unchecked. If a single radio button is unchecked, we can click it to make checked radio button. Once a radio button is checked, it cannot be marked as unchecked by user.

Why do they call them radio buttons?

Radio buttons are so called because they function like the channel presets on radios. A typical group of radio buttons. A group of radio buttons behaves like a single control. Only the selected choice is accessible using the Tab key, but users can cycle through the group using the arrow keys.


2 Answers

Yes it is possible.

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

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

like image 163
Raeesaa Avatar answered Oct 06 '22 01:10

Raeesaa


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.

like image 40
Joseph Earl Avatar answered Oct 06 '22 00:10

Joseph Earl