title: WebView doesn't resize
body: <p>I've developed a web application for Firefox OS, but I wanted to make it run "natively" in Android. My application consists of a dialogue box that is a <code>div</code> which fills the entire page when visible, which I've tested using the Firefox responsive design tool and it does resize correctly. When a soft keyboard appears, I would want the dialogue to resize to the viewport left over as there are some buttons at the bottom of the dialogue.</p>
  
  <p>I created an application with a single activity that contains just a <code>WebView</code>. I wanted to the view to resize when the keyboard appears, so I used:</p>
  
  <pre><code>android:windowSoftInputMode="stateUnspecified|adjustResize"
  </code></pre>
  
  <p>which didn't seem to make any difference to the <code>WebView</code> when the keyboard was visible. I looked online and there were many people complaining about this problem, but they all had the same thing in common, they were using the <code>Theme.Black.NoTitleBar.Fullscreen</code> theme, which I am not. I tried all of the solutions to that problem, but none of them worked.</p>
  
  <p>I then began to wonder if there was a bug in <code>WebView</code> which meant it didn't resize. So, I wrote a custom <code>View</code> which printed the dimensions in <code>onLayout</code>.</p>
  
  <pre><code>@Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
      Log.d(TAG, t + " " + r + " " + b + " " + l);
  }
  </code></pre>
  
  <p>And sure enough, the view was being resized correctly when the keyboard appeared and disappared. So, I did some more research and I found a few answers that said that you need to hide the <code>WebView</code>, reload it, and then show it again.</p>
  
  <pre><code>@Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
      Log.d(TAG, t + " " + r + " " + b + " " + l);
  
      mWebView.setVisibility(View.GONE);
      mWebView.layout(l, t, r, b);
      mWebView.invalidate();
      mWebView.reload();
      mWebView.setVisibility(View.VISIBLE);
  }
  </code></pre>
  
  <p>Again, this did not solve my problem. (And as a side point, this is a web-app with a single .html file and JS causes the state of all the elements in the app to change in runtime, so reloading it is not an option.)</p>
  
  <p>My question is whether anyone knows of a way of resizing a <code>WebView</code> once the content has been loaded when the keyboard is visible.</p>