我如何在运行时在相对布局中添加视图,使其自动对齐到父视图的顶部。比如我点击一个按钮然后添加一个EditText,这个EditText应该出现在按钮上面。
以下是示例代码:
以下是示例代码:
button = new Button(this); //here I am just checking if the button can come above the EditText
button.setText("I am a button");
params.addRule(RelativeLayout.BELOW, editText.getId());
params.addRule(RelativeLayout.ALIGN_PARENT_ABOVE);
relativeLayout.addView(button);
我完全无法对齐。 非常感谢任何提示。 提前致谢。