title: Android WebView flicker bug while animating view on device
body: <p>I am attempting to implement slide-in navigation (a la Facebook, Path, or Google+ Android apps).  The complete source to reproduce this bug <a href="https://bitbucket.org/robertkarl/slide-navigation-web-view" rel="noreferrer">can be found here</a>.</p>
  
  <p>When animating a <code>WebView</code> off the screen however, on a device, flickering occurs, as if the device is taking a bite out of my <code>WebView</code> just before pushing it off the screen. </p>
  
  <p><img src="https://i.stack.imgur.com/Z27L7.png" alt="WebView slide nav menu IN (device) "></p>
  
  <p>The artifact does not occur on the emulator! The animation proceeds smoothly.</p>
  
  <p><img src="https://i.stack.imgur.com/Y1Oky.png" alt="WebView slide nav menu IN (emulator)"></p>
  
  <p>Interestingly, this flickering seems to only occur when the view being animated is a <code>WebView</code>! Here is the same project using a TextView as the main content view.</p>
  
  <p><img src="https://i.stack.imgur.com/JC03G.png" alt="TextView slide nav menu IN (device)"></p>
  
  <p>Layout for the web view activity:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/blue" &gt;
  
      &lt;WebView
          android:id="@+id/web_content"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And for the text view activity:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/blue" &gt;
  
      &lt;TextView
          android:id="@+id/web_content"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Hello there. no flicker!"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true"
           /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Code called to slide the navigation menu in:</p>
  
  <pre><code> private void slideIn() {
          LinearLayout actionBarFrame = (LinearLayout) findViewById(android.R.id.content).getParent();
  
          LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
          menuView = inflater.inflate(R.layout.menu, null);
          menuView.setLayoutParams(new FrameLayout.LayoutParams(SIZE, LayoutParams.MATCH_PARENT, Gravity.LEFT));
          FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
          decorView.addView(menuView);
          decorView.bringChildToFront(actionBarFrame);
  
          FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) actionBarFrame.getLayoutParams();
          params.setMargins(SIZE, 0, -SIZE, 0);
          actionBarFrame.setLayoutParams(params);
  
          TranslateAnimation ta = new TranslateAnimation(-SIZE, 0, 0, 0);
          ta.setDuration(DURATION); 
          actionBarFrame.startAnimation(ta);
      }
  </code></pre>
  
  <p>And to slide it back out:</p>
  
  <pre><code>    private void slideOut() {
          LinearLayout actionBarFrame = (LinearLayout) findViewById(android.R.id.content).getParent();
  
          FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) actionBarFrame.getLayoutParams();
          params.setMargins(0, 0, 0, 0);
          actionBarFrame.setLayoutParams(params);
  
          TranslateAnimation ta = new TranslateAnimation(SIZE, 0, 0, 0);
          ta.setDuration(DURATION);
          ta.setAnimationListener(new  AnimationListener() {
              @Override 
              public void onAnimationEnd(Animation arg0) {
                  ((FrameLayout) getWindow().getDecorView()).removeView(menuView);
                  menuView = null;
              }
              @Override public void onAnimationRepeat(Animation arg0) { }
              @Override public void onAnimationStart(Animation arg0) { }
          });
          actionBarFrame.startAnimation(ta);
      }
  </code></pre>
  
  <p>I uploaded the code to <a href="https://bitbucket.org/robertkarl/slide-navigation-web-view" rel="noreferrer">BitBucket</a> as a public repo so you can try this project exactly as I have.</p>
  
  <p>Any help or ideas about why this is happening or how to fix it would be greatly appreciated! What is desired is to smoothly animate the <code>WebView</code> out of the picture and back in. Thanks!</p>