MultiLine EditText in Android Matrial design

<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 multiple lines. If the user hits "enter", the cursor should jump to the second line.

+3


source to share


2 answers


Add your EditText



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

      

+13


source


you need to install

by default in preview android:lines="5"

line limits on android:maxLines="10"



start input 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" />

      

0


source







All Articles