有没有一种简单的方法在
编辑:问题已解决。在xml中可以在
RadioGroup
中的RadioButtons
之间添加分隔符?我尝试使用divider
xml属性,但似乎没有起作用。如果相关的话,我的布局中的RadioGroup
不包含任何子视图;我是通过编程方式添加RadioButtons
的。编辑:问题已解决。在xml中可以在
RadioGroup
内添加除RadioButton
以外的视图。在我的情况下,你也可以通过编程方式实现,但要小心布局参数。Akki有正确的想法,这对我很有效。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);
}