使用 "next view button" 而不是 "new line button" 的 EditText 多行

EditText multiline with "next view button" instead of "new line button"

目标是将多行 EditTextandroid:inputType="textMultiLine" 和 "next view button" 一起使用,例如 android:inputType="text"(见图 2)。

<EditText
    android:id="@+id/addAffirmationContent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textMultiLine"
    android:maxLength="255"
    android:imeOptions="flagNoExtractUi" />

我尝试了很多组合: android:inputType, singleLine, nextFocusDown, nextFocusUp, nextFocusLeft, nextFocusRight, nextFocusForward, imeOptions, lines,但 android:inputType="textMultiLine" 总是强制换行按钮。

在 Nexus 5 上测试Android7.

图一:换行按钮:

图2:下一个视图按钮:

这三行组合应该用 "next"

替换你的 "enter"
<EditText 
    android:inputType="text"
    android:maxLines="1"
    android:imeOptions="actionNext" />

Android有很多"android:imeOptions”来指定键盘操作按钮

android:imeOptions="actionGo"
android:imeOptions="actionDone"
android:imeOptions="actionNext"
android:imeOptions="actionPrevious"
android:imeOptions="actionSend"

还有更多

我认为您要查找的内容与 this answer 中的相同:

在代码中:

editText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
editText.setRawInputType(InputType.TYPE_CLASS_TEXT);

在xml中:

android:inputType="textMultiLine"