LinearLayout.LayoutParams labellayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams textlayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
for(int i=0 ;i < 2;i++){
TextView label = new TextView(this);
EditText text = new EditText(this);
labellayoutParams.setMargins(40, 30, 30 , 0);
textlayoutParams.setMargins(60, 30, 30 , 0);
text.setHint("Type Here");
label.setText("some text");
ll.addView(label);
ll.addView(text);
}
this.setContentView(ll);
上記のコードは出力を次のように表示します
注: sometext を textview、_ __ _をedittext と仮定します。
some text ____________ some text _____________
しかし、私はこのような出力が欲しい
some text ____________
some text ____________
私は setOrientation(LinearLayout.VERTICAL) を試しましたが、これが好きです
some text
_____________
some text
_____________