您的位置:首页 > 移动开发

Webview输入框被输入法遮挡的问题

2013-12-16 13:25 435 查看
   private AdjustInputBoxPos(WebView webview) {
       mChildOfContent = webview;
       mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
           public void onGlobalLayout() {
               Rect r = new Rect();
               mChildOfContent.getWindowVisibleDisplayFrame(r);
               int usableHeightNow = r.bottom - r.top;
               if (usableHeightNow != usableHeightPrevious) {
                   int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
                   int heightDifference = usableHeightSansKeyboard - usableHeightNow;
                   if (heightDifference > (usableHeightSansKeyboard/4)) {
                       frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
                   } else {
                       frameLayoutParams.height = usableHeightSansKeyboard;
                   }
                   mChildOfContent.requestLayout();
                   usableHeightPrevious = usableHeightNow;
               }
           }
       });
       frameLayoutParams =  mChildOfContent.getLayoutParams();
   }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Android webview