EditText with Single Line, Line Wrapping and Done Action in Android
Regular formula for making an EditText- Single Line : no new line <Enter> allowed,- Line Wrapping : Single line wrapped...
Regular formula for making an EditText
– Single Line : no new line
– Line Wrapping : Single line wrapped into multiple lines, and
– Done Action : imeAction set as actionDone
is possible through only XML properties. That is,
android:inputType="text|textCapSentences"
android:singleLine="true"
android:lines="6"
android:imeOptions="actionDone"
But, only this is not enough. You need to set all these properties programatically.
You have to set all the extra options (other than layout_width and layout_height) programatically. That is,
EditText editText = (EditText) findViewById(R.id.edit_text);
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
editText.setLines(6);
editText.setHorizontallyScrolling(true);
editText.setSingleLine();