I am trying to add an editText dynamically to a relative layout. the layout contains an editText already. I need to add the new editText below the existing one.
EditText designation1 = new EditText(context);
designation1.setHint("designation");
designation1.setSingleLine(true);
and my layout is
layoutExp =
(RelativeLayout) childView.findViewById(R.id.relative_layout_edit_exp);
and my existing edit Text is
designation = (EditText)childView.findViewById(R.id.editTextDesignatn);
You need to use
RelativeLayout.LayoutParamsand specifiy the relative position with theaddRule(RelativeLayout.BELOW, ...)(this is the programmatic equivalent forandroid:belowXML attribute):