Skip to content Skip to sidebar Skip to footer

EditText With Single Text Line, Line Wrapping And Done Action?

I am trying to have an EditText with the following characteristics when editing with a soft key. I ready the documentation, searched here, play with the parameters but could not fi

Solution 1:

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);

Solution 2:

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.


Post a Comment for "EditText With Single Text Line, Line Wrapping And Done Action?"