How to add a view to a relative layout at runtime so that it aligns at the top of the parent. Let's say I add an EditText when the button is clicked. Now this EditText should appear so that the EditText goes above the Button.
here is an example of what i am doing.
button = new Button(this);
button.setText("I am a button");
params.addRule(RelativeLayout.BELOW, editText.getId());
params.addRule(RelativeLayout.ALIGN_PARENT_ABOVE);
relativeLayout.addView(button);
I can not perform alignment at all. Any key is welcome. Thanks at Advance.
source
share