0

我想在 relativelayout 的底部添加一个 linerlayout。我怎么能做到这一点?这是我正在使用的代码片段:

rl=new RelativeLayout(this);
ll = new LinearLayout(this);
buttons=new LinearLayout(this);

buttons.setOrientation(LinearLayout.HORIZONTAL);
ll.setOrientation(LinearLayout.VERTICAL);
//buttons.addRule();

LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
        LayoutParams.WRAP_CONTENT,
        LayoutParams.WRAP_CONTENT);
params.topMargin=450;
    //params.gravity = Gravity.BOTTOM;

rl.addView(ll);
rl.addView(buttons,params);
4

1 回答 1

0

我认为这样的事情应该可以工作:

rl=new RelativeLayout(this);
buttons=new LinearLayout(this);

buttons.setOrientation(LinearLayout.HORIZONTAL);

RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

rl.addView(buttons, lp);
于 2013-11-10T11:47:31.690 回答