我不能让我并排EditTexts
适应共享相同的空间。LinearLayout
这是执行此操作的代码:
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textFieldsLayout = (LinearLayout) findViewById(R.id.LinearLayout2);
for(int i=1; i <= 8; i++){
final EditText ed = new EditText(this);
ed.setText("" + i);
ed.setInputType(2);
ed.setLayoutParams(lparams);
textFieldsLayout.addView(ed);
}
}
这段代码设法添加EditText
到我的布局中,但它们并排出现,并且末尾有空白空间LinearLayout
,当我将参数更改为 时WRAP_CONTENT
,仅首先EditText
添加到布局中填充布局,而其他代码不会出现在那里,知道什么我在这里做错了吗?