A有线性布局底部的按钮。此布局中的其他内容可能会更改其高度。因此,按钮向上移动。如何使按钮在布局上“固定”?
答案 0 :(得分:0)
你必须使用RelativeLayout .... 动态代码
RelativeLayout rl = new RelativeLayout(this);
LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rl.setLayoutParams(params);
Button button = new Button(this);
button.setText("Previous");
LayoutParams params1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
button.setLayoutParams(params1);
rl.addView(button);