Q:

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

This has been asked a lot of times (1, 2, 3, 4…) but that was long ago, and neither of the answers work for me now. Hence posting the new question rather than bumping the old ones. Sorry for the duplicate.
I need to have an EditText, where:

it disallows line breaks;
on-screen keyboard should show "next" button instead of line break;
originally it is one line high;
but when content overflows, it wraps on words like multi-line text.

If you have Gmail or Inbox app, I need exactly the functionality of email subject field.
Here's the approximate picture — only that the keyboard should show an › button, not a caret button.

I've been trying all kinds of EditText properties and their combinations, including ones with android:inputType="textEmailSubject", but I always either have it single-line and not wrapping, or I have this caret button and it allows for line breaks. Another interesting fact is that I can get it to work with a non-stock keyboard (AnySoftKeyboard), but not with the stock one.
Please help

A:

I found out you have to do this by code because some XML attributes get ignored in particular cases.
In your layout, make sure you do not set textMultiline as input type, then use the following code:
mEditText.setMaxLines(Integer.MAX_VALUE); // Or specify a lower value if you want
mEditText.setHorizontallyScrolling(false);

