Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

radio button multiple rows

I want to display 6 radio buttons of same radio group. But all the 6 radio buttons remain on same line and goes off the screen. How to display them in two rows (3 radio buttons each)? I tried everything possible for me (I am new to android).

like image 733
Niraj Burde Avatar asked Apr 09 '26 02:04

Niraj Burde


1 Answers

From searching around, there doesn't appear to be a way of doing it, as RadioGroup uses LinearLayout, which does not wrap. As radio buttons must be direct children to the radio group, you can't add sub-layouts to radio group.

This means you will have to implement this layout behaviour manually. Two possible options are:

  • Create a copy of RadioGroup to extend a different layout, or at least allow you control it dynamically.
  • Implement your own custom layout to replace RadioGroup that extends a layout of your choice, and implements OnClickListener. There's a good example here.
like image 55
BDFun Avatar answered Apr 17 '26 01:04

BDFun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!