This does not solve issue.
Correct solution is: Override below method on your main activity:
public boolean dispatchTouchEvent(MotionEvent ev)
{
View view = getCurrentFocus();
boolean ret = super.dispatchTouchEvent(ev);
if(drawer_open) {
//如果滑块打开什么也不做 } else { if (view instanceof EditText) { View w = getCurrentFocus(); int scrcoords[] = new int[2]; w.getLocationOnScreen(scrcoords); 浮动 x = ev.getRawX() + w.getLeft() - scrcoords[0]; 浮动 y = ev.getRawY() + w.getTop() - scrcoords[1];
if (ev.getAction() == MotionEvent.ACTION_UP && (x < w.getLeft() || x >= w.getRight() || y < w.getTop() || y > w.getBottom())) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0);
}
}
return ret;
}