实现edittext的多行显示

我使用 LayoutParams动态的创建一个edittex。使用MATCHPARENT为其设置宽度和高度。使用下面的代码,但是运行不了:

EditText editor = ....;
LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1);
editor.setLayoutParams(params);
editor.setGravity(Gravity.LEFT | Gravity.TOP);
editor.setBackgroundColor(Color.WHITE);
editor.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
editor.setTextColor(Color.BLACK);
editor.setFocusableInTouchMode(true);
editor.setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE | EditorInfo.TYPE_TEXT_FLAG_IME_MULTI_LINE);
editor.setMaxLines(Integer.MAX_VALUE);
editor.setHorizontallyScrolling(false);
editor.setTransformationMethod(null);

代码提示输入几行,并且在键盘上显示一个“输入”按钮,但当我在edittext中输入文本,如果edit text宽度不够时是水平滚动的。如何让edittext多行显示呢?

这样试下
editor.setSingleLine(false);

editor.setSingleLine(false);
editor.setHorizontalScrollBarEnabled(false);

也可以是:

android:scrollHorizontally="false"