我有一个相对布局,我正在以编程方式创建:
RelativeLayout layout = new RelativeLayout( this );
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
Run Code Online (Sandbox Code Playgroud)
现在我有两个按钮,我想在这个相对布局中添加.但问题是RelatiiveLayout左侧的两个按钮都显示在彼此之间.
buttonContainer.addView(btn1);
buttonContainer.addView(btn2);
Run Code Online (Sandbox Code Playgroud)
现在我想知道如何以编程方式设置按钮的android:layout_alignParentRight="true"或 android:layout_toLeftOf="@id/btn"属性",就像我们在xml中一样?