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 find a working configuration.
EditView
view on the screen has height for a few lines (e.g. 3-4).I could achieve {1,2,3} and {1,2,4} but not {1,2,3,4}. My rational is that since the content is a single line (no line breaks) the Enter key is not used and thus should be able to be changed to the Done label.
My setup code looks like this
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE); editText.setHorizontallyScrolling(false); editText.setSingleLine(false); // This does not work. Soft keyboard has Enter action. editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
Is it possible? Any suggestion?
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With