I'm creating a list of EditTexts programmatically. In all I give a margin of 20dp and put one below the other. The problem is that textbox2 always stays above 1, the other textboxes are in the perfect position. follows the code written to create the edit texts:
int numeroParcelas = 15;
for (int e = 0; e < numeroParcelas; e++){
final EditText myEditText = new EditText(mRlayout.getContext());
RelativeLayout.LayoutParams editParams = new RelativeLayout.LayoutParams(DrawerLayout.LayoutParams.MATCH_PARENT, DrawerLayout.LayoutParams.WRAP_CONTENT);
myEditText.setId(e);
myEditText.getLayoutParams();
myEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
myEditText.setHint("Parcela " + (e + 1) + ":");
myEditText.setHintTextColor(R.color.colorAccent);
myEditText.setTextSize(20);
if ( e > 0 ) {
editParams.addRule(RelativeLayout.BELOW, e -1 );
editParams.setMargins(0,20,0,0);
}else{
editParams.addRule(RelativeLayout.ALIGN_PARENT_START);
}
myEditText.setLayoutParams(editParams);
mRlayout.addView(myEditText);
}