I've a RadioGroup
inside a ConstraintLayout
. I've a list of Radio buttons (those are comming from remote server call). So the number of radio buttons is not fixed. Sometimes it can be 5, sometimes 10 or any size. I've to show those radio buttons column-wise, like below image.
I've follow this thread to add radio buttons dynamically. I can show radio buttons horizontally or vertically. To show horizontal I used this code:
healthCheckRadioGroup.setOrientation(LinearLayout.HORIZONTAL);
for(String healthPlan: healthCheckPlanList){
RadioButton radioButton = new RadioButton(getContext());
radioButton.setId(View.generateViewId());
radioButton.setText(healthPlan);
healthCheckRadioGroup.addView(radioButton);
}
Result of above code is, a single horizontal list of radio buttons. and most of the buttons are out of the parent layout (I mean invisible)
Please help me to obtain the output. Thanks.