2

I tried setting my EditText to multiline once and it worked. But when I changed some stuff on the EditText to make it look a bit cool, it doesn't type in multiline anymore.

<EditText
        android:ems="10"
        android:inputType="textMultiLine"
        android:text="  "
        android:id="@+id/reqdesc"
        android:layout_width="fill_parent"
        android:layout_height="110dp"
        android:hint="   Enter your request here"
        android:textSize="18sp"
        android:maxLength="80"
        android:background="@layout/rounded_border_edittext"
        android:lines="8"
        android:minLines="2"
        android:gravity="top|left"
        android:maxLines="4"
        android:layout_marginTop="14dp"
        android:layout_below="@+id/post"
        android:layout_alignParentStart="true" />
LMae
  • 81
  • 1
  • 9

2 Answers2

4
reqdesc = (EditText) myView.findViewById(R.id.reqdesc);
reqdesc.setInputType(InputType.TYPE_CLASS_TEXT |
             InputType.TYPE_TEXT_FLAG_MULTI_LINE |
            InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
InputFilter[] fArray = new InputFilter[1];
    fArray[0] = new InputFilter.LengthFilter(maxLength);
    reqdesc.setFilters(fArray);

It now works, I put these lines of codes under onCreate.

halfer
  • 19,824
  • 17
  • 99
  • 186
LMae
  • 81
  • 1
  • 9
0

try this:

Find your Edittext

etReqdesc = (EditText) findViewById(R.id.reqdesc);

Now programetically call: inside onCreate()

etReqdesc.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
etReqdesc.setSingleLine(false);
etReqdesc.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);

your edittext should look like:

<EditText
    android:ems="10"
    android:inputType="textMultiLine"
    android:text="  "
    android:id="@+id/reqdesc"
    android:layout_width="fill_parent"
    android:layout_height="110dp"
    android:hint="   Enter your request here"
    android:textSize="18sp"
    android:background="@layout/rounded_border_edittext"
    android:gravity="top|left"
    android:layout_marginTop="14dp"
    android:layout_below="@+id/post"
    android:layout_alignParentStart="true" />

Remove android:maxLength="80" attribute.

rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62