2012-09-08 87 views
1

A具有线性布局底部的按钮。此布局中的其他内容可能会更改其高度。由于这个按钮向上移动。如何使按钮在布局上“固定”?线性布局的固定按钮

回答

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);