3

我想以编程方式做这样的事情 -

<RelativeLayout1>
  <LinearLayout name = 1>
  <LinearLayout below = 1>
<RelativeLayout1>

我尝试这样做:

LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)mButtonContainer.getLayoutParams();

参数有weight字段,width字段,但没有layout_below...感谢您的帮助!

4

1 回答 1

12

addRule

RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
relativeParams.addRule(RelativeLayout.BELOW, idOfTheViewBelow);
于 2013-06-07T13:45:43.383 回答