title: Dialog animation messed up by webview: android bug?
body: <p>I made a dialog with both Enter and Exit slow animations. But the dialog contains a webview <code>myMsg</code> (that loads a local file, so no delay) and messes up the animation.</p>
  
  <p>With the code below (no webview), the dialog works perfectly, animating both at Enter and at Exit. However, if I uncomment the
  line <code>//builder.setView(myMsg)</code>, the Exit animation still works perfectly, but the Enter animation is not performed (or performed too fast). Funny thing, if I minimize the app and maximize it again, the Enter dialog animation is performed fine.</p>
  
  <p>It's like the webview load messes the Enter animation. I tried to show the dialog after the webview is loaded, with the same results.</p>
  
  <p>Isn't that crazy?? Any clue of what is happening, and how to solve it? Any help would be appreciated.</p>
  
  <p>Here's the relevant part of the code:</p>
  
  <pre><code>    WebView myMsg = new WebView(context);
      myMsg.loadUrl("file:///android_asset/page.html");
  
      AlertDialog.Builder builder = new AlertDialog.Builder(context);
      builder.setIcon(R.drawable.ic_launcher);
      //builder.setView(myMsg);
      builder.setTitle("Some Title");
      final AlertDialog dialog = builder.create();
  
      WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
      lp.windowAnimations = R.style.AnimateDialog;
  
      dialog.show();
      dialog.getWindow().setAttributes(lp);
  </code></pre>
  
  <p>and in styles,</p>
  
  <pre><code>&lt;style name="AnimateDialog"&gt;
      &lt;item name="android:windowEnterAnimation"&gt;@anim/in_left&lt;/item&gt;
      &lt;item name="android:windowExitAnimation"&gt;@anim/out_left&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I tried with a <code>setWebViewClient</code>, but without luck (without the line <code>dialog.getWindow().setLayout...</code> the Enter animation simply does not work):</p>
  
  <pre><code>    WebView myMsg = new WebView(context);
      myMsg.getSettings().setJavaScriptEnabled(true);
      myMsg.loadUrl("file:///android_asset/" + page);
      myMsg.setBackgroundColor(0);
      myMsg.setSoundEffectsEnabled(true);
  
      AlertDialog.Builder builder = new AlertDialog.Builder(context);
      builder.setIcon(R.drawable.ic_launcher);
      builder.setTitle("SomeTitle");
      builder.setView(myMsg);
      final AlertDialog dialog = builder.create();
  
      myMsg.setWebViewClient(new WebViewClient() {
          @Override
          public void onPageFinished(WebView view, String url) {
              super.onPageFinished(view, url);
              dialog.show();
              dialog.getWindow().setWindowAnimations(R.style.AnimateDialog);
              dialog.getWindow().setLayout(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT);
          }
      }
  </code></pre>
  
  <p><strong>EDIT2</strong></p>
  
  <p>I also tried with Dialog instead of AlertDialog, with an xml layout, getting identical problems (tried also <code>WebView.loadData</code> instead of <code>WebView.loadUrl</code>, same problems):</p>
  
  <pre><code>    final Dialog d = new Dialog(context);
      d.setContentView(R.layout.viewhtml);
      d.setTitle("SomeTitle");
      // Without this, Enter animation does not work
      d.getWindow().setLayout(WindowManager.LayoutParams.FILL_PARENT,
              WindowManager.LayoutParams.FILL_PARENT);
      WebView wv = (WebView) d.findViewById(R.id.webview);
      wv.loadUrl("file:///android_asset/" + page);
      wv.setBackgroundColor(0);
      d.getWindow().setWindowAnimations(R.style.AnimateDialog);
      wv.setWebViewClient(new WebViewClient() {
          @Override
          public void onPageFinished(WebView view, String url) {
              super.onPageFinished(view, url);
              d.show();
          }
      });
  </code></pre>
  
  <p>and this is Dialog xml layout file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  
  &lt;WebView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/webview"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:soundEffectsEnabled="true" &gt;
  &lt;/WebView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>EDIT3</strong></p>
  
  <p>I just realized that the same problem happens when using a <code>TextView</code> with <code>TextView.setText(Html.fromHTML...)</code> instead of a <code>WebView</code>. Moreover, if I add <code>dialog.getWindow().setLayout(600,800)</code> <em>after</em> <code>dialog.show()</code>, the animation is performed as expected. So it seems that the problem is that the animation is not performed without knowing beforehand the dialog size?</p>