16
<android.support.design.widget.TextInputLayout
            android:id="@+id/float_edit_description"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/ll4"
            android:layout_marginTop="5dp">

            <EditText
                android:id="@+id/edit_description"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:focusable="true"
                android:gravity="top|left"
                android:hint="Description"
                android:inputType="text"
                android:maxLines="3"
                android:paddingTop="0dp"
                android:scrollbars="vertical"
                android:textColor="@android:color/black"
                android:textColorHint="@color/hint_grey" />
        </android.support.design.widget.TextInputLayout>

I want to make the above EditText to have multi line. If the user press "enter" the cursor should get down to the second line.

0

2 Answers 2

42

Add your EditText

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

you have to set

default lines in preview by android:lines="5"

limits of lines by android:maxLines="10"

start of typing by android:gravity="start"

try this code:

<EditText
                android:id="@+id/et_content"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/ic_launcher"
                android:gravity="start"
                android:hint="hint"
                android:inputType="text"
                android:lines="5"
                android:maxLines="10"
                android:padding="10dp"
                android:textColor="#000" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.