How to find out if the keyboard (dis) appears in Android?

I have an EditText and I want to give it more lines when the keyboard appears. Therefore, I am looking for something like "OnKeyboardAppearsListener", but cannot find it. I think it should exist, but perhaps in a different way ...

+7
source share
1 answer

You need @Override onConfigurationChanged to be able to handle changes at runtime:

 @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Checks whether a hardware or on-screen keyboard is available if (newConfig.keyboardHidden == Configuration.KEYBOARDHIDDEN_NO) { Toast.makeText(this, "Keyboard visible", Toast.LENGTH_SHORT).show(); } else if (newConfig.keyboardHidden == Configuration.KEYBOARDHIDDEN_YES) { Toast.makeText(this, "Keyboard hidden", Toast.LENGTH_SHORT).show(); } } 

An example from here . Look here for keyboard-related fields (among other things) that you might want to use.


Change (RivieraKid): Changed to reflect a hard or on-screen keyboard.

+5
source

All Articles