How to allow multi-line in Android\'s EditText
view?
if some one is using AppCompatEditText then you need to set inputType="textMultiLine" here is the code you can copy
<androidx.appcompat.widget.AppCompatEditText
android:padding="@dimen/_8sdp"
android:id="@+id/etNote"
android:minLines="6"
android:singleLine="false"
android:lines="8"
android:scrollbars="vertical"
android:background="@drawable/rounded_border"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_25sdp"
android:layout_marginTop="32dp"
android:layout_marginEnd="@dimen/_25sdp"
android:autofillHints=""
android:gravity="start|top"
android:inputType="textMultiLine"
/>
for background
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/_5sdp"/>
<stroke android:width="1dp" android:color="#C8C8C8"/>
</shape>
To disable number of lines that was previously assigned in theme use xml attribute: android:lines="@null"
All of these are nice but will not work in case you have your edittext inside upper level scroll view :) Perhaps most common example is "Settings" view that has so many items that the they go beyond of visible area. In this case you put them all into scroll view to make settings scrollable. In case that you need multiline scrollable edit text in your settings, its scroll will not work.
android:inputType="textMultiLine"
This code line work for me. Add this code you edittext in your xml file.
Just add this
android:inputType="textMultiLine"
in XML file on relevant field.
Another neat thing to do is to use android:minHeight
along with android:layout_height="wrap_content"
. This way you can set the size of the edit when it's empty, and when the user inputs stuff, it stretches according to how much the user inputs, including multiple lines.