I am trying to create a multiline EditText by code. This is what I use:
EditText txt = new EditText(this);
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f);
txt.setLayoutParams(lp);
txt.setSingleLine(false);
txt.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
But it is still in one single line.
Combining all above answers was the correct answer so here it is:
Try this
You may also use this:
This should do it
In addition to the above suggestions - you might want to set the below additional parameters if you are not able to get this working
If you are changing the height of the edittext programmatically then you might want to request a layout too by calling requestLayout().
The combination that finally worked for me was:
At least partially I was using
setInputType
for configuring several different options so it made more sense than some of the other possibilities.