How to get width and height of a Webview in android

后端 未结 12 1162
长发绾君心
长发绾君心 2021-01-04 17:13

I want to determine the width and the height of the WebView. I have already tried it using:

webView.getWidth();
webView.getHeight();
         


        
12条回答
  •  南笙
    南笙 (楼主)
    2021-01-04 17:47

    you are checking size of webview too early. you can try this in following method

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        // TODO Auto-generated method stub
        super.onWindowFocusChanged(hasFocus);
                webView.getWidth();
                webView.getHeight();
    }
    

提交回复
热议问题