Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Responsive website show on Web view out of mobile width(Not Responsive) other way in Chrome Looks Good

I am using webview to load the responsive website but it shows the width outside to the mobile size.

I open the link in a mobile Chrome browser and it looks good...

I mean to say the width does not fit to screen size of mobile; it shows out of width.

I am also using these... for <viewport> tag for controlling its presentation.

    WebSettings settings = webview.getSettings();
    settings.setJavaScriptEnabled(true);

    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true); 

Also I am using setInitialScale for webview render properly.

    webview.setInitialScale((int) 1.0);

but I am getting the website load not responsive as according to size... it shows the width is outside to screen size... which comes with scroll

Application works fine in Lollipop, Marshmallow etc. But does not work in Jellybean etc. But the Link works well with latest chrome in all devices but does not work in webview.

I also set this....

 <meta name="viewport" content="width=device-width, initial-scale=1">

Screenshot

enter image description here

like image 402
Arjun saini Avatar asked Aug 12 '16 07:08

Arjun saini


People also ask

Why does my website look different on mobile?

For most people, the 3G or 4G mobile network connection on their phone is much slower than their home or office wifi network. With that in mind, if your website relies on large images, which haven't been compressed for the web and take a few seconds to load on your computer, they may not load at all on your phone.

Why is my website not responsive on mobile?

Let's state the obvious to begin with. The number one reason why your website might be failing to work on a mobile device is that it is simply not mobile responsive. This means the website doesn't proportionally resize to different size screens.


3 Answers

Try This:

WebView browser = (WebView) findViewById(R.id.webview);
browser.getSettings().setLoadWithOverviewMode(true);
browser.getSettings().setUseWideViewPort(true);
like image 177
Amy Avatar answered Nov 13 '22 11:11

Amy


web.setInitialScale(1);
    web.getSettings().setLoadWithOverviewMode(true);
    web.getSettings().setUseWideViewPort(true);

try this code may be solve your issue.

like image 31
Nirmit Avatar answered Nov 13 '22 13:11

Nirmit


is your web view layout_width="match_parent"?

you can also use:`

setting.setBuiltInZoomControls(true);
webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());

before:

settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
like image 37
mohammadreza khalifeh Avatar answered Nov 13 '22 11:11

mohammadreza khalifeh