EditText with single text line, line wrapping and Done action?

半世苍凉 提交于 2019-12-03 09:38:36

This combination (and the specific order of the EditText method calls) should produce the configuration that you want:

  editText.setInputType(
    InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
  editText.setSingleLine(true);
  editText.setLines(4); // desired number of lines
  editText.setHorizontallyScrolling(false);
  editText.setImeOptions(EditorInfo.IME_ACTION_DONE);

Just add

editText.setHorizontallyScrolling(false);
editText.setMaxLines(Integer.MAX_VALUE);

with your edittext instance in your activity programmatically.

It configures the EditText instance so that the user edits a single-line string that is displayed with soft-wrapping on multiple lines with IME options.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!