我有一个用作滑动菜单的 DrawerLayout
,目前我使用 InputMethodManager
在显示 DrawerLayout
时关闭键盘
public void onDrawerOpened(View drawerView) {
supportInvalidateOptionsMenu();
// Hide Soft-Keyboard
InputMethodManager imm = (InputMethodManager) MainActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(drawerView.getApplicationWindowToken(), 0);
}
有没有办法让软键盘保持打开状态并在其顶部显示 DrawerLayout
?所以当抽屉布局关闭时, Activity/软键盘仍处于相同状态?
谢谢。
最佳答案
试试这段代码:
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput
(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
关于android - 键盘上的抽屉布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22909785/