如何以编程方式为LinearLayout指定layout_below? [英] How do I specify layout_below programmatically for a LinearLayout?

查看:102
本文介绍了如何以编程方式为LinearLayout指定layout_below?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过编程方式做类似的事情-

I want to do something like this programmatically -

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

我尝试这样做:

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

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

params have weight field, width field, but does not have layout_below... Thanks for any help!

推荐答案

addRule

RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
relativeParams.addRule(RelativeLayout.BELOW, idOfTheViewBelow);

这篇关于如何以编程方式为LinearLayout指定layout_below?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆