gpt4 book ai didi

android - 如何以编程方式为 LinearLayout 指定 layout_below?

转载 作者:太空宇宙 更新时间:2023-11-03 11:40:02 24 4
gpt4 key购买 nike

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

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

我尝试这样做:

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

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

最佳答案

使用addRule

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

关于android - 如何以编程方式为 LinearLayout 指定 layout_below?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16985646/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com