Code example for WebView

Methods: getScale, computeScroll, getContentHeight, getScrollY

0
	public Float getScrollRatio() {
		if (state != State.FINISHED) {
			Log.d(TAG, "Not returning any scroll ratio, as webview state is " + state);
			return null; 
		} 
		webView.computeScroll();
		int scrollPosition = webView.getScrollY();
		int height = webView.getContentHeight();
		float scale = webView.getScale();
		Float ratio = (float) scrollPosition / (float) (scale * height);
		Log.d(TAG, "scroll ratio of view " + webView + " is " + ratio);
		return ratio;
	} 
}