<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.
You can make your EditTexts multi-line by added certain attributes to the EditTexts View. Also remember to set android:layout_height:wrap_content.
in this way we can create a multiline TextView widget in android app. we can assign android:text attribute value by this way android:text="Line1 \n Line2 \n Line3" for a TextView widget. this value will display the specified TextView widget's text on three lines.
The maxLines attribute is used to set the maximum line a TextView widget can have. You can prevent the TextView from creating multiple lines by setting the maxLines value as 1 .
Add your EditText
<EditText
...
android:inputType="textMultiLine"
/>
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" />
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