title: Why does pinch-to-zoom not work in my Android WebView?
body: <p>I have an activity with a layout like this:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="${relativePackage}.${activityClass}" &gt;
  
      &lt;include  layout="@layout/window_title" /&gt;
  
      &lt;WebView
          android:id="@+id/webView"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_centerHorizontal="true" 
          android:layout_below="@+id/linear_layout"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here is how I'm configuring it:</p>
  
  <pre><code>    // Enable JavaScript.
      WebView myWebView = (WebView) findViewById(R.id.webView);
      WebSettings webSettings = myWebView.getSettings();
      webSettings.setJavaScriptEnabled(true);
  
      // Settings so page loads zoomed-out all the way.
      webSettings.setLoadWithOverviewMode(true);
      webSettings.setUseWideViewPort(true);
      webSettings.setBuiltInZoomControls(true);
  </code></pre>
  
  <p>Here's the version setting from my manifest file:</p>
  
  <pre><code>&lt;uses-sdk
      android:minSdkVersion="10"
      android:targetSdkVersion="17" /&gt;
  </code></pre>
  
  <p>I'm trying to load this page in the WebView:</p>
  
  <pre><code>https://new.livestream.com/lcboise
  </code></pre>
  
  <p>The page loads just fine, but I can't pinch to zoom. I've tried different combinations of the WebView settings (above, including others not listed) but it just won't zoom.</p>
  
  <p>Observations:</p>
  
  <p>1) Loading up a different page I'm using (<a href="https://lcboise.infellowship.com/UserLogin" rel="noreferrer">https://lcboise.infellowship.com/UserLogin</a>) in the EXACT same WebView allows me to zoom.</p>
  
  <p>2) My main test device, where is DOES NOT work, is a HTC One running v4.4.3 of Android.</p>
  
  <p>3) I can load, and zoom, the livestream page on an older test device I'm using that's running v2.3.3 of Android.</p>
  
  <p>Is it possible that something in the page itself is breaking the WebView running on the HTC One? If so, any guesses as to might be doing it?</p>
  
  <p>Update [SOLUTION]:</p>
  
  <p>Here is what I had to add to my WebView to get pinch-to-zoom to work:</p>
  
  <pre><code>    myWebView.setWebViewClient(new WebViewClient() {
  
          @Override
          public void onPageFinished(WebView view, String url) {
              String javascript="javascript:document.getElementsByName('viewport')[0].setAttribute('content', 'initial-scale=1.0,maximum-scale=10.0');";
              view.loadUrl(javascript);
          }
      });
  </code></pre>