Smooth Horizontal Scrolling In Webview
Solution 1:
You cannot attach a scroller to a webview however you can make use of the gesture to do the same.
The gesture detects the fling using this method
onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
Give the velocityX, velocityY to the scoller method along with other parameters
fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY)
scan the computeScrollOffset() value to find the getCurrX(),getCurrY() positions.
Extend the webview and override the methods onTouchEvent(MotionEvent ev), dispatchTouchEvent(MotionEvent ev) to return false so that by default the touch events are not consumed by the webview itself. Now implement the gestureListener and override the onfling method mentioned above. pass the velocity and other parameters to the scroller. Start a loop to scan the computeScrollOffset() value to find the getCurrX() and getCurrY() and invalidate the view each time. Pass this value to scroll the webview as needed.
Please let me know in case you need anything.
Post a Comment for "Smooth Horizontal Scrolling In Webview"