在android中的Web视图中的额外滚动和空间

时间:2013-09-30 15:15:38

标签: android webview

我正在使用WebView,我在其中打开网站,但滚动更多。它在浏览器中滚动较少,但在webview中滚动更多。我如何在Web视图中与浏览器相同。

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);

        final WebView myWebView = (WebView)findViewById(R.id.testwebview);
        final ProgressBar myPB = (ProgressBar)findViewById(R.id.testprogressbar);

        WebSettings webSettings = myWebView.getSettings();
        webSettings.setSavePassword(false);
        webSettings.setSaveFormData(false);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportZoom(false);
        webSettings.setAppCacheEnabled(true);

        // Add WebViewClient to be notified of page load
        myWebView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url){
                // Show webview and hide progress bar
                myWebView.setVisibility(View.VISIBLE);
                myPB.setVisibility(View.INVISIBLE);
            }
        });
        myWebView.loadUrl("http://pmtestonline.com");
    }
}

1 个答案:

答案 0 :(得分:0)

我认为你应该看看这两个问题

WebView doesn't resize

但是我发现你需要每次都创建新的WebView

WebView height = wrap_content with changing font size doesn't work

答案也是......

以编程方式编辑新的webview

Webview in programmatically created RelativeLayout

这也是Im trying to programmatically insert a WebView into my Code