Android(安卓)检测键盘是否显示及隐藏键盘
16lz
2021-12-04
Android 检测键盘是否显示及隐藏键盘的方法~~
package com.newland.util;import android.app.Activity;import android.view.View;import android.view.inputmethod.InputMethodManager;/** * 系统输入法键盘 检测工具 * * @author yuyh * */public class IMEUtil {/** * 隐藏键盘 * @param context */public static void hideIme(Activity context) {if (context == null)return;final View v = context.getWindow().peekDecorView();if (v != null && v.getWindowToken() != null) {InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);imm.hideSoftInputFromWindow(v.getWindowToken(), 0);}}/** * 检查系统键盘是否显示 * @param context * @return */public static boolean isSysKeyboardVisiable(Activity context) {final View v = context.getWindow().peekDecorView();if (v != null && v.getWindowToken() != null) {return true;}return false;}}
更多相关文章
- android customactivityoncrashchau 程序崩溃处理
- 第3.2.1节 android基本视图
- Android(安卓)DrawerLayout抽屉效果
- TextView设置一行最多显示6个字是什么属性?
- Android程序横竖屏切换
- android中将中文以粗体显示
- Android软键盘弹出,界面整体上移的问题
- Android应用程序键盘(Keyboard)消息处理机制分析(12)
- EditText设置不自动获取焦点,点击后才获取,并弹出软键盘