Allow multi-line in EditText view in Android? Allow multi-line in EditText view in Android? android android

Allow multi-line in EditText view in Android?


By default all the EditText widgets in Android are multi-lined.

Here is some sample code:

<EditText    android:inputType="textMultiLine" <!-- Multiline input -->    android:lines="8" <!-- Total Lines prior display -->    android:minLines="6" <!-- Minimum lines -->    android:gravity="top|start" <!-- Cursor Position -->    android:maxLines="10" <!-- Maximum Lines -->    android:layout_height="wrap_content" <!-- Height determined by content -->    android:layout_width="match_parent" <!-- Fill entire width -->    android:scrollbars="vertical" <!-- Vertical Scroll Bar -->/>


You may find it better to use:

<EditText ...android:inputType="textMultiLine"/>

This is because android:singleLine is deprecated.


This works for me, actually these 2 attributes are important: inputType and lines. Besides, you may need a scrollbar, the code below shows how to make one:

 <EditText        android:id="@+id/addr_edittext"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:gravity="top|left"        android:inputType="textEmailAddress|textMultiLine"        android:lines="20"        android:minLines="5"        android:scrollHorizontally="false"        android:scrollbars="vertical" />