title: Android: Get the scroll position of a WebView
body: <p>I'm new to Android.</p>
  <p>I would like to simply know where on a page the user has scrolled. When a certain point on the web page appears at the bottom of the screen, I want to trigger an event. But this code causes an exception. I know that WebView inherits <code>getScrollY()</code> from View. Am I not implementing it correctly?</p>
  <p>Thanks in advance.</p>
  <pre><code>public class Scroll extends Activity {
  
      public WebView webview;
      public float yPos;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          WebView webview = new WebView(this);
          setContentView(webview);
          webview.loadUrl(&quot;file:///android_asset/Scroll.html&quot;);
      }
  
  
      public boolean onTouchEvent(final MotionEvent event) {
          if (event.getAction() == MotionEvent.ACTION_MOVE) {
              yPos = webview.getScrollY();
              Log.v(&quot;Scroll&quot;, &quot;yPos = &quot; + yPos); 
          }
          return false;
      }
  }
  </code></pre>