Web View with zoom

Asked

Viewed 434 times

1

I have a web view being loaded onto the screen (mounted by an internal HTML) which sometimes opens with zoom and others without the zoom. I don’t want her to open with zoom, I need it to open on the full screen!

Here the excerpt from the layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <WebView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/webViewReport"
        android:layout_below="@+id/button_report"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true" />

</LinearLayout>

Here I load the HTML and WV pro game

montaHTML();

wv = (WebView) findViewById(R.id.webViewReport);
ws = wv.getSettings();
ws.setJavaScriptEnabled(true);
ws.setSupportZoom(true);
ws.setDefaultTextEncodingName("utf-8");
wv.loadData(html, "text/html; charset=utf-8", "UTF-8");
  • You may need a meta viewport tag on the page to work well. Be advised that Webview on Android is always a lottery, always have a chance the site does not appear with the desired zoom, because there are small implementation differences between Android versions, manufacturers and models.

1 answer

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.