EditText with word-wrap, no line breaks and with keyboard action set to "next",

This has been asked many times ( 1 , 2 , 3 , 4 ...), but it has been a long time, and none of the answers work for me now. Therefore, raise a new question, and not stumble on the old. Sorry for the duplicate.

I need to have an EditText where:

  • it prohibits line breaks;
  • the on-screen keyboard should display the β€œnext” button instead of the break line;
  • initially it is one line high;
  • but when the content overflows, it wraps around words like multi-line text.

If you have a Gmail or Inbox app, I really need the functionality of the email subject field.

Here, an approximate image is just what the keyboard should show & rsaquo ;, and not the carriage button.

Screenshot

I tried all kinds of EditText properties and their combinations, including with android:inputType="textEmailSubject" , but I always have a single line and not a wrapper, or I have this caret button and this allows line breaks. Another interesting fact is that I can get it to work with a non-warehouse keyboard (AnySoftKeyboard), but not with a margin.

Please, help

+6
source share
1 answer

I found out that you need to do this with code, because some XML attributes are ignored in some cases.

In your layout, make sure not to set textMultiline as the input type, then use the following code:

 mEditText.setMaxLines(Integer.MAX_VALUE); // Or specify a lower value if you want mEditText.setHorizontallyScrolling(false); 
+7
source

All Articles