【发布时间】:2011-06-06 01:07:31
【问题描述】:
我有一个以编程方式创建的相对布局:
RelativeLayout layout = new RelativeLayout( this );
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
现在我有两个按钮,我想在这个相对布局中添加它们。但问题是两个按钮都显示在 RelatiiveLayout 的左侧,彼此重叠。
buttonContainer.addView(btn1);
buttonContainer.addView(btn2);
现在我想知道如何以编程方式设置 android:layout_alignParentRight="true"
还是像我们在 xml 中那样设置按钮的 android:layout_toLeftOf="@id/btn" 属性?
【问题讨论】:
标签: android android-relativelayout android-layoutparams