How to hide keyboard when editText has focus
I want the editText window to be clickable so that the user can scroll the text, but I don't want the keyboard to appear. I've tried all of these, but they don't do what I want:
In XML:
android:editable="false"
android:windowSoftInputMode="stateAlwaysHidden"
android:inputType="none"
This disables it:
editText.setInputType(EditorInfo.TYPE_NULL);
This only works with API 21 and above:
editText.setShowSoftInputOnFocus(false);
+3
source to share
3 answers
Set edit text on touch listener. This will make the edit text intact because it is set to return true.
EditTextHere.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
Make an expression that it will allow the user to touch the edit text, returning it to false.
0
source to share