Ich erstelle benutzerdefinierte Radiobuttons in Code. Hier ist die individuelle Radiobutton-KlasseEinstellung von Abstand/Abstand zwischen Radiobuttons, die durch die Laufzeit erstellt werden
public class SurveyRadioButton extends RadioButton {
private int value;
private int questionId;
public SurveyRadioButton(Context context) {
super(context);
setBackgroundResource(R.drawable.selector_checkbox);
setButtonDrawable(new StateListDrawable());
setPadding(10, 20, 10, 20);
setTextSize(17);
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public int getQuestionId() {
return questionId;
}
public void setQuestionId(int questionId) {
this.questionId = questionId;
}
}
und es geht Skript erstellen
LinearLayout.LayoutParams matchWrapLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
LinearLayout root = (LinearLayout) findViewById(R.id.root);
RadioGroup radioGroup = new RadioGroup(SplashActivity.this);
radioGroup.setLayoutParams(matchWrapLayoutParams);
{
for (int ii = 0; ii < 5; ii++) {
SurveyRadioButton radioButton = new SurveyRadioButton(this);
radioButton.setLayoutParams(matchWrapLayoutParams);
radioButton.setText("arda");
radioButton.setSelected(false);
radioGroup.addView(radioButton);
}
root.addView(radioGroup);
}
Diese Codes macht, dass die Ansichten, aber ich Lücke zwischen Radiobuttons hinzufügen möchten. Rand in die Layout-Parameter einstellen funktioniert nicht. Ich frage mich, was wird sein?