Is there a simple way to add a divider between RadioButtons inside a RadioGroup? I've tried using the divider xml attribute and it doesn't seem to be working. In case it's relevant, the RadioGroup in my layout does not contain any child views; I'm adding the RadioButtons programmatically.
EDIT: Problem solved. You can add views besides RadioButton inside RadioGroup in the xml. In my case, you can also do it programmatically, but be careful about your layout params. Akki had the right idea, and this worked for me:
for (int i = 0; i < items.size(); i++) {
if (i > 0) {
// add a divider with height of 1 pixel
View v = new View(this);
v.setLayoutParams(new RadioGroup.LayoutParams(LayoutParams.MATCH_PARENT, 1));
v.setBackgroundColor(android.R.color.darker_gray);
mRadioGroup.addView(v);
}
RadioButton rb = new RadioButton(this);
/* set other properties ... */
mRadioGroup.addView(rb);
}
