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.
On my phone, changing imeOptions and inputType does nothing; setting movementMethod and/or scrollBarStyle will screw the component so badly so that the user will be unable to select any text; isVerticalScrollBarEnabled and isHorizontalScrollBarEnabled does nothing; the best I could do is to use
(
txt.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
seems to be unnecessary) but that won't display any scrollbars in the god-damn EditText. Ultimately I gave up and I'm inflating a layout snippet anytime I need a multi-line EditText. Here's the layout:And here's Anko snippet:
Development on Android sucks so hard.
Include this in your code :
maxlines will be the maximum number of lines you want to allow in your EditText.