How to allow multi-line in Android's EditText
view?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With