I have LinearLayout
in that I have RadioGroup
in RadioGroup
I am adding layout dynamically using addview()
method of LinearLayout
. I am able to add view but my view not getting full width.
here is my code
radiogroup_ans.setOrientation(LinearLayout.VERTICAL);
radiogroup_ans.removeAllViews();
radiogroup_ans.clearCheck();
for (int i = 0; i < subjectDetailMain.getSubjectdetail().get(0).getPackageDetailArrayList().size(); i++)
{
LinearLayout lnr=new LinearLayout(this);
RadioButton rb_answer = new RadioButton(this);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT);
rb_answer.setLayoutParams(p);
rb_answer.setId(i);
rb_answer.setTag(i);
LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = vi.inflate(R.layout.packagelist_layout,(ViewGroup) null);
p = new LinearLayout.LayoutParams(RadioGroup.LayoutParams.MATCH_PARENT, RadioGroup.LayoutParams.WRAP_CONTENT,1.0f);
v.setLayoutParams(p);
lnr.addView(rb_answer);
lnr.addView(v);
radiogroup_ans.addView(lnr);
}
here is output hows its looks
here is image how i want it
LinearLayout lnr=new LinearLayout(this);
LayoutParams LParams = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
lnr.setLayoutParams(LParams);
Set Layout params to lnr also