How do I detect if software keyboard is visible on Android Device or not?

前端 未结 30 1384
情书的邮戳
情书的邮戳 2020-11-22 10:59

Is there a way in Android to detect if the software (a.k.a. \"soft\") keyboard is visible on screen?

30条回答
  •  无人及你
    2020-11-22 11:31

    try this:

    InputMethodManager imm = (InputMethodManager) getActivity()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
    
        if (imm.isAcceptingText()) {
            writeToLog("Software Keyboard was shown");
        } else {
            writeToLog("Software Keyboard was not shown");
        }
    

提交回复
热议问题