在布局根节点加上下面三行
android:id="@+id/view_parent" android:clickable="true" android:focusableInTouchMode="true"
在代码中监听view_parent的FocusChangeListener事件
view_parent.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { if(b){ InputMethodManager manager = ((InputMethodManager)mActivity.getSystemService(mActivity.INPUT_METHOD_SERVICE)); if (manager != null) manager.hideSoftInputFromWindow(view.getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS); } } });