android 软键盘的使用

AndroidManifest.xml文件中界面对应的<activity>里加入
android:windowSoftInputMode="adjustPan"   键盘就会覆盖屏幕(解决了view随着键盘弹出而整体上移)
android:windowSoftInputMode="stateVisible|adjustResize"   屏幕整体上移

 

EditText默认不弹出软件键盘

<activity android:name=".Main"

                  android:label="@string/app_name"
                  android:windowSoftInputMode="adjustUnspecified|stateHidden"
                 android:configChanges="orientation|keyboardHidden|screenSize" />

 

让EditText失去焦点,使用EditText的clearFocus方法

 edit.clearFocus();

 

 

 

显示:

InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0,
InputMethodManager.HIDE_NOT_ALWAYS);

隐藏:

InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mLoginButton.getWindowToken(), 0);

posted on 2015-12-10 15:50  赵磊磊  阅读(195)  评论(0编辑  收藏  举报

导航