Reputation: 1536
I load a content in the webview. At this time, I want the content to fit with the screen size that I don't need to scroll. However, the function setInitialScale()
is not working. Can you tell me what's the problem in my code?
public class WebViewActivity extends Activity {
private static WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setSupportZoom(true);
webView.loadUrl("http://developer.android.com/reference/packages.html");
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
webView.setPadding(0, 0, 0, 0);
webView.setInitialScale(100); // here is the problem
});
}
}
Upvotes: 2
Views: 7950
Reputation: 6201
You can use this to fixes size based on screen size.
WebView browser = (WebView) findViewById(R.id.webview);
browser.getSettings().setLoadWithOverviewMode(true);
browser.getSettings().setUseWideViewPort(true);
Upvotes: 3