First of all, I just want to take a note: http://www.jb51.net/article/64820.htm
At first sight, feel not too reliable, because before all is to see this processing, according to listen to a root layout of size, but that effect is not good, I do not want to use, just want to look for, see this when the test, the effect is great. Also learned the
/** * Monitor soft keyboard status * * @param activity * @param listener */public static void Addonsoftkeyboardvisiblelistener (activity activity, final Onsoftkeyboardvisiblelistener listener) { final View Decorview = Activity.getwindow (). Getdecorview (); Decorview.getviewtreeobserver (). Addongloballayoutlistener (New Viewtreeobserver.ongloballayoutlistener () { @ Override public void Ongloballayout () { rect rect = new Rect (); Decorview.getwindowvisibledisplayframe (rect); int displayhight = rect.bottom-rect.top; int hight = Decorview.getheight (); Boolean visible = (double) Displayhight/hight < 0.8; Listener.onsoftkeyboardvisible (visible);}} ); }
The interface itself can be defined as follows:
Public interface Onsoftkeyboardvisiblelistener { void onsoftkeyboardvisible (Boolean visible);
And finally, thank you, big God.
Adnroid Monitoring Soft Keyboard display