How to add padding around a WebView

后端 未结 7 1579

My layout file defines a WebView, underneath which there are some fixed height buttons.




        
7条回答
  •  伪装坚强ぢ
    2020-12-16 09:47

    @Sergii's code didn't work for me, but following does

    mWebView.setWebViewClient(new mWebViewClient(){
            @Override
            public void onPageFinished(WebView web, String url) {
                web.loadUrl("javascript:(function(){ document.body.style.paddingTop = '55px'})();");
            }
        });
    

    You can change paddingTop to paddingBottom, paddingRight, paddingLeft too. Change the 55pxvalue to whatever you desire. Additionally, enable JavaScript for your webview

      webView.settings.javaScriptEnabled = true
    

提交回复
热议问题