I am trying to create a dynamic speaker using LayoutParams.MATCHPARENT for its width and height. I tried the following code but it still does not work.
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.setSingleLine(false); 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);
The code above allows me to enter several lines, and the 'ENTER' button is displayed on the keyboard, but as you enter text in the editor, the edit text scrolls horizontally if the text is not wide enough to display the text. Can someone please help me how to make edittext multi-line?
android android-edittext multiline
user1553837
source share