css - android webview goes more than full width for responsive sites -


i have simple webview:

<webview  xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/webview"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     /> 

which called this:

protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          webview mywebview = (webview) findviewbyid(r.id.webview);         mywebview.loadurl("http://example.com");     } 

the problem site trying render doesn't go responsive mode. width goes beyond screen causing me scroll.

i have tried widths including: fill_parent, match_parent, , wrap_content , none of them work.

what can make webpage render responsive, staying in confines of screen without scrolling horizontally?

you missing couple of setup calls make webview render more mobile browser:

mywebview.getsettings().setusewideviewport(true); mywebview.getsettings().setloadwithoverviewmode(true); 

optionally, can enable pinch-zooming:

mywebview.getsettings().setsupportzoom(true); mywebview.getsettings().setbuiltinzoomcontrols(true); mywebview.getsettings().setdisplayzoomcontrols(false); 

and @hylianpuffball correctly noted, website should ideally using <viewport> tag controlling presentation.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -