title: Why is hardware acceleration not working on my View?
body: <p>I'm using <a href="http://facebook.github.io/rebound/" rel="nofollow noreferrer">Facebook's Rebound library</a> to replicate the bouncy animations seen in their chat heads implementation. The problem is, most of the time the animation stutters. A few pictures will explain this better. Here's the buttery-smooth chat heads animation:</p>
  
  <p><img src="https://i.stack.imgur.com/uxtUY.gif" alt="Facebook Messenger"></p>
  
  <p>And here's my attempt (notice how the animation for the white <code>View</code> skips nearly all frames):</p>
  
  <p><img src="https://i.stack.imgur.com/7QCJj.gif" alt="Stuttering animation"></p>
  
  <p>Once in a while it works smoothly:</p>
  
  <p><img src="https://i.stack.imgur.com/ydKQJ.gif" alt="Smooth animation"></p>
  
  <p>Below is the code I'm using currently (the entire project is <a href="https://github.com/vickychijwani/BubbleNote/tree/eb708e3910a7279c5490f614a7150009b59bad0b" rel="nofollow noreferrer">up on Github</a> if you want to set it up quickly). I'm guessing this has something to do with hardware acceleration not being enabled correctly on my <code>View</code>. There are 2 <code>Spring</code>s in my <code>SpringSystem</code>, one for the "bubble" (the Android icon) and another for the content (the white <code>View</code> that is displayed on tapping the bubble). Any help on how to solve this issue would be greatly appreciated. Thanks.</p>
  
  <p><code>AndroidManifest.xml</code>:
  </p>
  
  <pre><code>    &lt;application android:hardwareAccelerated="true" ...&gt;
          ...
      &lt;/application&gt;
  </code></pre>
  
  <p><code>AppService.java</code>:
  </p>
  
  <pre><code>    // the following code is in AppService#onCreate()
      // AppService extends android.app.Service
      // full code at https://github.com/vickychijwani/BubbleNote
  
      mContent.setLayerType(View.LAYER_TYPE_HARDWARE, null);
  
      final Spring bubbleSpring = system.createSpring();
      bubbleSpring.setCurrentValue(1.0);
      bubbleSpring.addListener(new SpringListener() {
          @Override
          public void onSpringUpdate(Spring spring) {
              float value = (float) spring.getCurrentValue();
              params.x = (int) (mPos[0] * value);
              params.y = (int) (mPos[1] * value);
              mWindowManager.updateViewLayout(mBubble, params);
              // fire the second animation when this one is about to end
              if (spring.isOvershooting() &amp;&amp; contentSpring.isAtRest()) {
                  contentSpring.setEndValue(1.0);
              }
          }
  
          // ...
      });
  
      final Spring contentSpring = system.createSpring();
      contentSpring.setCurrentValue(0.0);
      contentSpring.addListener(new SpringListener() {
          @Override
          public void onSpringUpdate(Spring spring) {
              // always prints false?!
              Log.d(TAG, "hardware acc = " + mContent.isHardwareAccelerated());
              float value = (float) spring.getCurrentValue();
              // clamping is required to prevent flicker
              float clampedValue = Math.min(Math.max(value, 0.0f), 1.0f);
              mContent.setScaleX(value);
              mContent.setScaleY(value);
              mContent.setAlpha(clampedValue);
          }
  
          // ...
      });
  </code></pre>