title: How to overscroll a custom view (surfaceview)
body: <p>I have a custom SurfaceView which is managed by a worker thread. I am using code very similar to the code in the following blog post to manage the SurfaceView:</p>
  
  <p><a href="http://android-coding.blogspot.com/2011/05/drawing-on-surfaceview.html" rel="nofollow noreferrer">http://android-coding.blogspot.com/2011/05/drawing-on-surfaceview.html</a></p>
  
  <p>My custom SurfaceView is scrollable in the sense that I listen for touch events, send them to a gesture detector, and implement onScroll. I keep track of the scroll distances in some member variables (both x-axis and y-axis) and translate any coordinates by the appropriate amounts when drawing to the canvas. I also clamp the scroll distances and can easily calculate and store any overscroll amounts when clamping.</p>
  
  <p>This all works fine.</p>
  
  <p>The problem is that I want to show the standard Android overscroll effects on my custom SurfaceView. I tried calling overScrollBy manually but it didn't work and my best guess is because I am drawing the view from a worker thread which means the view's onDraw is never called.</p>
  
  <p>I found the following stackoverflow post about customizing the overscroll effects:</p>
  
  <p><a href="https://stackoverflow.com/questions/5897909/how-can-i-change-the-overscroll-color-in-android-2-3-1">How can I change the OverScroll color in Android 2.3.1?</a></p>
  
  <p>That post is not intended for SurfaceViews but I could probably adapt the code. That said, is there a better way? I want to show the exact same overscroll effects that are shown elsewhere. Making copies of the overscroll drawables and attempting to duplicate the overscroll logic seems... ugly.</p>