android 软件盘相关

1.

问题: 当工程底部有标签栏等控件时,点击编辑框软件盘会把底部栏顶到上面,

解决:在AndroidManifest上使用标签栏等控件的activity中加入:android:windowSoftInputMode="adjustPan"

要是想故意把控件提到软键盘的上面   解决:http://blog.csdn.net/yhqbsand/article/details/9066781

2.

弹出软键盘:

InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); 
imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); 
让软键盘消失:
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); 
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); 

很多应用中对于一个界面比如进入搜索界面或者修改信息等等情况,为了用户体验应该自动弹出软键盘而不是让用户主动点击输入框才弹出(因为用户进入该界面必然是为了更改信息)。具体实现这种效果如下:
     EditText  editText.setFocusable(true);
    editText.setFocusableInTouchMode(true);
   editText.requestFocus();
    InputMethodManager inputManager = (InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
     inputManager.showSoftInput(editText, 0);
首先要对指定的输入框请求焦点。然后调用输入管理器弹出软键盘。

你可能感兴趣的:(android 软件盘相关)