Ok everyone knows that to hide a keyboard you need to implement:
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hi
Use OnFocusChangeListener.
For example:
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
hideKeyboard();
}
}
});
Update: you also may override onTouchEvent()
in your activity and check coordinates of the touch. If coordinates are outside of EditText, then hide the keyboard.