点击空白处隐藏自定义view和隐藏键盘
2017-07-27 本文已影响8人
陈楚炼
在自定义类中
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isFocused()) {
if (messageViewListener!=null){
messageViewListener.onHiderBottomBar();
}
// 隐藏键盘
IBinder token = sendContainer.getWindowToken();
InputMethodManager inputMethodManager = (InputMethodManager) getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(token,
InputMethodManager.HIDE_NOT_ALWAYS);
}
return super.onTouchEvent(event);
}