我在xml中有一个单选按钮组,这些按钮是通过编程动态生成的。如何在编程时在按钮之间添加间距。
我认为可能需要使用LayoutParams
,但我的对象没有明显的setPadding
或setMargins
方法。
这是我尝试的代码:
RadioButton currentButton = new RadioButton(context);
currentButton.setText(item.getLabel());
currentButton.setTextColor(Color.BLACK);
//add padding between buttons
LayoutParams params = new LayoutParams(context, null);
params. ... ??????
currentButton.setLayoutParams(params);