您的位置:首页 > 其它

安卓软键盘的自动弹起/隐藏

2015-09-23 22:09 162 查看
Toggle软键盘:

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


隐藏软键盘:

InputMethodManager im = (InputMethodManager) v.getContext()
.getSystemService( Context.INPUT_METHOD_SERVICE );
if (im.isActive()){
im.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
}


Manifest下设置:

//一个例子,适用于切入页面即触发EditText
<activity
android:name="com.uustudio.unote.activity.NoteEditActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden|locale"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustPan" >
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: