Allow multi-line in EditText view in Android?


Question

How to allow multi-line in Android's EditText view?

1
434
10/24/2018 11:45:07 AM

Accepted Answer

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|left" <!-- 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 -->
/>
1087
7/23/2017 5:03:37 AM

You may find it better to use:

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

This is because android:singleLine is deprecated.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon