我希望在水平布局中有两列EditTexts,它位于根布局中。在设计器中我添加了一个按钮来添加两个EditTexts,但是我找不到以编程方式编辑android:layout_weight的方法。
我的代码是
private void BtnAddSet_Click(object sender, EventArgs e)
{
var editText = new EditText(this);
editText.Text = "";
editText.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent, 0.3f);
var editText2 = new EditText(this);
editText2.Text = "";
editText2.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent, 0.3f);
var horizontalLayout = new LinearLayout(this);
horizontalLayout.Orientation = Orientation.Horizontal;
horizontalLayout.AddView(editText);
horizontalLayout.AddView(editText2);
this.rootLayout.AddView(horizontalLayout);
}