How to make Android EditText vertically deployed when

I have this EditText

<EditText android:layout_width="match_parent" android:layout_height="72dp" android:hint="@string/write_message" android:textColorHint="@color/primary_color" android:ems="10" android:imeOptions="actionDone" android:inputType="textImeMultiLine" android:id="@+id/message_input" android:layout_gravity="center_horizontal" android:backgroundTint="@color/primary_color"/> 

When the field is filled with user-entered text, it scrolls to the right to make room for more text, I don’t like this behavior, and would prefer the EditText window to expand upwards when it needs more space? Is there any way to do this? Thanks.

+6
source share
1 answer

Yes, this actually includes two things:

  • Performing EditText accepting multi-line input.
  • Increase its height when adding more text strings.

Therefore, to achieve this goal you need to configure:

 android:inputType="textMultiLine" android:layout_height="wrap_content" 

(remember the difference between textMultiLine and textImeMultiLine ).

Full XML snippet:

 <EditText android:layout_width="match_parent" android:inputType="textMultiLine" android:layout_height="wrap_content" android:hint="@string/write_message" android:textColorHint="@color/primary_color" android:ems="10" android:imeOptions="actionDone" android:id="@+id/message_input" android:layout_gravity="center_horizontal" android:backgroundTint="@color/primary_color"/> 
+16
source

Source: https://habr.com/ru/post/980282/


All Articles