安卓监听输入法

    mWebView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            int screenHeight = mWebView.getRootView().getHeight();
            int myHeight = mWebView.getHeight();
            int heightDiff = screenHeight - myHeight;
            Log.e("onGlobalLayout", "screenHeight=" + screenHeight);
            Log.e("onGlobalLayout", "myHeight=" + myHeight);

            if (heightDiff > 96) {
                Log.e("onGlobalLayout", "Soft keyboard showing");
            } else {
                Log.e("onGlobalLayout", "Soft keyboard hidden");
            }
        }
    });

你可能感兴趣的:(安卓监听输入法)