抱歉我的英文。我有一个动态创建的TextView和ImageView,它们被添加到LinearLayout中。但是当我开始编写TextView时,它会改变它的大小,从而减少ImageView。下图是
大小的示例
final LinearLayout row = new LinearLayout(this);
row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
row.setOrientation(LinearLayout.HORIZONTAL);
//params editTExt
android.widget.LinearLayout.LayoutParams paramsEtext = new android.widget.LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f);
paramsEtext.gravity = Gravity.LEFT;
//params image View
LinearLayout.LayoutParams paramsImageView = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0.25f);
paramsImageView.gravity = Gravity.CENTER_VERTICAL;
//create edit text
final EditText etext = new EditText(QuicklyCreateQwestions.this);
etext.setLayoutParams(paramsEtext);
//add et in ArrayList
et.add(etext);
//set text in textView
etext.setText(qwestions.get(i).toString());
row.addView(etext);
//add ImageView in edit text
final ImageView imV = new ImageView(this);
imV.setLayoutParams(paramsImageView);
imV.setImageResource(R.drawable.t_del_poll);
imV.setId(i);
//set button in layaut
row.addView(imV);
//action if button click
imV.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
row.removeView(etext);
row.removeView(imV);
}
});
//add editText and button in layaut
LinearLayoutTextQwestions.addView(row);