Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow multi-line in EditText view in Android?

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

like image 461
Adham Avatar asked Nov 20 '10 16:11

Adham


People also ask

What is TextInputLayout Android?

TextInputLayout is a view container that is used to add more features to an EditText. It acts as a wrapper for EditText and has some features like: Floating hint. Animation that can be disabled or enabled. Error labels that display error messages when an error occurs.


2 Answers

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 --> /> 
like image 88
Shardul Avatar answered Sep 21 '22 20:09

Shardul


You may find it better to use:

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

This is because android:singleLine is deprecated.

like image 40
Knossos Avatar answered Sep 21 '22 20:09

Knossos