Usama Sarwar
Usama Sarwar

Reputation: 9020

Whole HTML page does not show up in a WebView

I have an HTML page opened in a WebView in my Android app. But that page is not auto-sized to fit in the WebView, hence some part of the page does not show up there in the WebView. I want that, when an HTML page is opened in a WebView, the whole page must fit in the WebView. I have gone through other related questions and I have tried them, but it did not work for me.
I have added these lines to WebView:

    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setLoadWithOverviewMode(true); 

but nothing happened, is there any other way of implementing this thing? Help is always appreciated.

Upvotes: 0

Views: 1114

Answers (1)

user2655114
user2655114

Reputation: 31

This works with me:

WebView myWebView = (WebView) findViewById(R.id.webView1);

myWebView.getSettings().setLoadWithOverviewMode(true);

myWebView.getSettings().setUseWideViewPort(true);

myWebView.loadUrl("http://saudi-arabia.gold-price-today.com/");

If this code doesn't work for you, try to use it in new project.

Upvotes: 3

Related Questions