android 判断输入法是否打开

来源:互联网 发布:适合mac用的办公软件 编辑:程序博客网 时间:2024/05/22 14:47

if (getActivity().getWindow().getAttributes().softInputMode == WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) {
   InputMethodManager imm = (InputMethodManager) getActivity().getApplicationContext() .getSystemService(Context.INPUT_METHOD_SERVICE);
   imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
  }
1 0