Android Webview - Webpage should fit the device screen
You can use this
WebView browser = (WebView) findViewById(R.id.webview); browser.getSettings().setLoadWithOverviewMode(true); browser.getSettings().setUseWideViewPort(true);
this fixes size based on screen size.
You have to calculate the scale that you need to use manually, rather than setting to 30.
private int getScale(){ Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int width = display.getWidth(); Double val = new Double(width)/new Double(PIC_WIDTH); val = val * 100d; return val.intValue();}
Then use
WebView web = new WebView(this);web.setPadding(0, 0, 0, 0);web.setInitialScale(getScale());
Friends,
I found a lot of import and great informations from you. But, the only way works for me was this way:
webView = (WebView) findViewById(R.id.noticiasWebView);webView.setInitialScale(1);webView.getSettings().setJavaScriptEnabled(true);webView.getSettings().setLoadWithOverviewMode(true);webView.getSettings().setUseWideViewPort(true);webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);webView.setScrollbarFadingEnabled(false);webView.loadUrl("http://www.resource.com.br/");
I am working on Android 2.1 because of the kind of devices from the company. But I fixed my problem using the part of informations from each one.
Thanks you!