如何检查软键盘显示在活动屏幕上?

时间:2012-08-24 08:45:54

标签: android android-softkeyboard visible

  

可能重复:
  Is there a way to tell if the soft-keyboard is shown?

在我想检查的应用程序中,活动屏幕上会显示软键盘。

plz help

1 个答案:

答案 0 :(得分:1)

如果您感兴趣,有一种解决方法,您可以使用getCurrentFocus()返回焦点的视图并检查它是否是EditText的实例,如果是,那么您知道软键盘是可见的,前提是软键盘中的主要输入,而不是物理键盘。

protected boolean IsSoftKeyboardVisible(){
if(getCurrentFocus()!=null && getCurrentFocus() instanceof EditText){
        return true;
    }
return false;
}