标签:otto system odm get 显示 context tin spl led
/**
* 判断键盘是否显示
*
* @return true 显示
*/
public static boolean isSoftShowing(Activity activity) {
//获取当前屏幕内容的高度
int screenHeight = activity.getWindow().getDecorView().getHeight();
//获取View可见区域的bottom
Rect rect = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
return screenHeight - rect.bottom != 0;
}
/**
* 隐藏键盘
*/
public static void hide(Activity activity) {
if (isSoftShowing(activity)){
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
}
标签:otto system odm get 显示 context tin spl led
原文地址:https://www.cnblogs.com/haoziCute/p/10640851.html