2012-09-08 130 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);