In my application i have added radio button dynamically, successfully i can add and get the values my problem is UI, its not aligned properly, layout weight dint make any change in my UI
check it out my coding
Have Text View and Radion Button
LinearLayout.LayoutParams mainparams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
mainparams.setMargins(0, 8, 0, 0);
My Dynamic Textview
LinearLayout li = new LinearLayout(Appointmentdetails.this);
li.setOrientation(LinearLayout.HORIZONTAL);
li.setLayoutParams(mainparams);
LinearLayout.LayoutParams mainparams1 = new LinearLayout.LayoutParams(
0, LayoutParams.WRAP_CONTENT);
mainparams1.setMargins(0, 10, 0, 0);
mainparams1.weight = 1f;
TextView tv = new TextView(this);
tv.setTextSize(18);
tv.setTypeface(Typeface.DEFAULT_BOLD);
tv.setTypeface(MyriadPro);
tv.setLayoutParams(mainparams1);
tv.setText(Alldata.question.get(i).getgQuestion());
tv.setSingleLine();
tv.setPadding(25, 10, 0, 0);
tv.setTextColor(Color.parseColor("#009099"));
tv.setMarqueeRepeatLimit(10);
tv.setEllipsize(TruncateAt.MARQUEE);
tv.setSelected(true);
My dynamic Radio button
RadioGroup rg = new RadioGroup(Appointmentdetails.this);
// rg.setLayoutParams(lparams1);
gAnswerList.add("Select vlaue");
for (int j = 0; j < helptext.split(Expressions).length; j++) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params.setMargins(5, 0, 0, 0);
// Edittext.setLayoutParams(lparams1);
params.weight = 1.6f;
RadioButton rb = new RadioButton(Appointmentdetails.this);
rb.setText(helptext.split(Expressions)[j].toString());
rb.setId(j);
rb.setLayoutParams(params);
rg.addView(rb);
}
li.addView(tv);
li.addView(rg);
mQuestionLayout.addView(li);
My Curent Output
My radio button need to align as like edittext, kindly help me to get the proper solution,
Thanks in advance,