Android 线性布局上的固定按钮
A在线性布局的底部有一个按钮。此布局中的其他内容可能会更改其高度。因此,按钮向上移动。如何使按钮在布局上“固定”?您必须使用RelativeLayout。。。。 代码的动态特性Android 线性布局上的固定按钮,android,button,android-linearlayout,Android,Button,Android Linearlayout,A在线性布局的底部有一个按钮。此布局中的其他内容可能会更改其高度。因此,按钮向上移动。如何使按钮在布局上“固定”?您必须使用RelativeLayout。。。。 代码的动态特性 RelativeLayout rl = new RelativeLayout(this); LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
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);